this popping 例外をJSONObject.fromObject
ここで 'true' = 'true' pq are a single quote within another single quotes にする必要がある場合、誰かがこの API のある種のエスケープ文字を知っていますか?
public static void main(String[] args) {
String json = "{gA:[ {c:{f:'C#',o:'=',v1:' ('true' = 'true' ) ' }}]}";
final Map<String, Object> map = new HashMap<String, Object>();
try {
JsonConfig cfg = new JsonConfig();
cfg.setRootClass(LinkedHashMap.class);
cfg.setArrayMode(JsonConfig.MODE_OBJECT_ARRAY);
cfg.setHandleJettisonSingleElementArray(false);
JSONObject jsonObjeto = JSONObject.fromObject(json, cfg);
System.out.println(jsonObjeto.toString());
} catch (final JSONException e) {
e.printStackTrace();
}
}
例外:
net.sf.json.JSONException: Expected a ',' or '}' at character net.sf.json.JSONException: Expected a ',' or '}' at character 31 of {gA:[ {c:{f:'C#',o:'=',v1:' ('true' = 'true' ) ' }}]}
at net.sf.json.util.JSONTokener.syntaxError(JSONTokener.java:499)
at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:1099)
at net.sf.json.JSONObject.fromObject(JSONObject.java:159)
at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:348)
at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:1008)
at net.sf.json.JSONObject.fromObject(JSONObject.java:159)
at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:348)
at net.sf.json.JSONArray._fromJSONTokener(JSONArray.java:1131)
at net.sf.json.JSONArray.fromObject(JSONArray.java:125)
at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:351)
at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:1008)
at net.sf.json.JSONObject._fromString(JSONObject.java:1201)
at net.sf.json.JSONObject.fromObject(JSONObject.java:165)
at br.com.michel.json.JsonTest.main(JsonTest.java:28)
私が望むjsonの出力:
{"ga": [{"c": {"f", "C#", "o": "=", "v1": "('true' = 'true')"}}]}