2
我有,我想创建一个JSONObject的如何创建包含类似字符的字符串,JSON对象“:”,在Java
import org.json.JSONObject;
JSONObject json=new JSONObject("{success=false, errorMessage=Application with appId : [randomAppId] not registered, errorCode=102}");
System.out.println("JSON:"+json.toString());
但现在我是一个字符串“[”和“]”由于:
,[
,]
这样的字符在字符串内部,因此得到例外。
堆栈跟踪:
Exception in thread "main" org.json.JSONException: Expected a ',' or '}' at character 53
at org.json.JSONTokener.syntaxError(JSONTokener.java:410)
at org.json.JSONObject.<init>(JSONObject.java:222)
at org.json.JSONObject.<init>(JSONObject.java:402)
感谢亨利......它的工作.. :) – DevCoder
不起作用: ' –
@NitinBansal这绝对有效。也许你的问题是不同的。 – Henry