I am using JSONObject for entering data and computing something out if it. Lets suppose i entered data in form :-
JSONObject obj = new JSONObject();
obj.put("uuid", newImageUuid);
obj.put("type", "image");
obj.put("value", base64ImagePath);
For SDK version above 19 i get it in perfect order but for versions below it the order of the json reverses. Value comes first , then type, then uuid.
I have tried this way :-
Map obj=new LinkedHashMap();
obj.put("uuid", newImageUuid);
obj.put("type", "image");
obj.put("value", base64ImagePath);
StringWriter data = new StringWriter();
JSONValue.writeJSONString(obj, data);
Data is in ordered manner and in the form in which i want but i cant make use of this data as type of it is StringWriter. But when i convert this data back into JSONObject , result will be in unordered fashion . I have tried many methods like storing in linkedhashmaps and then converting into JSONObjects but of no use. Could anyone please help to it.