Answer the question
In order to leave comments, you need to log in
How to serialize JSON?
How to serialize JSON?
JSONObject resultJson = new JSONObject();
resultJson.put("name","foo");
resultJson.put("num",new Integer(100));
resultJson.put("is_vip",new Boolean(true));
resultJson.put("nickname",null);
System.out.print(obj.toString());
Answer the question
In order to leave comments, you need to log in
So what's the point of serializing json?) This is actually a string ready for use)
toString() is exactly what you need.System.out.print(resultJson.toString());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question