我有一个字符串,我想从中创建一个 jsonobject
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)