1

I have a json string that has multiple sub objects, While converting this string using

JSONObject jsonObject=(JSONObject) JSONValue.parse(jsonString);

the insertion order is missed out in jsonObject especially dataCollection object. Is there a way or any library to preserve elements order during the conversion?

Sample Json:

{
  "Id": "f4a305705b064074a0ed15531031f3d0",
  "FirstName": "Name",
  "description": "Description",
  "data": {
    "dataCollection": {
      "Location": 883000,
      "Type": "Vehicle",
      "isRegistered": true,
      "wheels": 4,
      "isPowerSteered": "yes"
    },
    "Region": "India"
  }
}
JavaCreeper
  • 193
  • 2
  • 5
  • 9
  • 1
    Possible duplicate of [Keep the order of the JSON keys during JSON conversion to CSV](https://stackoverflow.com/questions/4515676/keep-the-order-of-the-json-keys-during-json-conversion-to-csv) – Pavneet_Singh Nov 14 '17 at 13:48
  • 2
    according to this, json should be unordered https://stackoverflow.com/questions/4515676/keep-the-order-of-the-json-keys-during-json-conversion-to-csv – codebrane Nov 14 '17 at 13:49

0 Answers0