Code example for JSONStringer

Methods: toString

0
import org.json.JSONStringer; 
 
public class SBJsonWriter extends NSObject { 
	public static String stringWithObject(Object value){
		String contentString ="";
		JSONStringer js = new JSONStringer();
		serialize(js, value);
		contentString = js.toString();
		return contentString;
	} 
	/** 
	 * ÐòÁл¯ÎªJSON 
	 * @param js json¶ÔÏó 
	 * @param o	´ýÐèÐòÁл¯µÄ¶ÔÏó 
	 */ 
	private static void serialize(JSONStringer js, Object o) {
		if (isNull(o)) {
			try { 
				js.value(null);
			} catch (JSONException e) {