net.sf.xmlform.util.JSONUtils Maven / Gradle / Ivy
package net.sf.xmlform.util;
import org.json.JSONException;
import org.json.JSONObject;
/**
* @author Liu Zhikun
*/
public class JSONUtils {
static public String jsonToString(JSONObject jsonObj){
return jsonToString(jsonObj,0);
}
static public String jsonToString(JSONObject jsonObj,int indentFactor){
if(indentFactor>0)
try {
return jsonObj.toString(indentFactor);
} catch (JSONException e) {
wrapJSONException(e);
return null;
}
else
return jsonObj.toString();
}
static public void wrapJSONException(JSONException e){
throw new IllegalStateException(e.getLocalizedMessage(),e);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy