Example, same objects, parsed differently when in array and by self:
String test = "{\"c\":\"{\\\"k\\\":\\\"k\\\", \\\"l\\\":\\\"l\\\"}\"}";
JSONObject jsonObject = JSONObject.fromObject(test);
System.out.println("test = " + test);
System.out.println("json = " + jsonObject);
String test2 = "{\"a\":[{\"c\":\"{\\\"k\\\":\\\"k\\\", \\\"l\\\":\\\"l\\\"}\"}]}";
jsonObject = JSONObject.fromObject(test2);
System.out.println("test = " + test2);
System.out.println("json = " + jsonObject);
Produces:
test = {"c":"{\"k\":\"k\", \"l\":\"l\"}"}
json = {"c":"{\"k\":\"k\", \"l\":\"l\"}"}
test = {"a":[{"c":"{\"k\":\"k\", \"l\":\"l\"}"}]}
json = {"a":[{"c":{"k":"k","l":"l"}}]}
You can see that in case2 String was parsed to object by mistake