JSONObject : Why JSONObject changing the order of attributes [duplicate]

See the answer here: JSON order mixed up

You cannot and should not rely on the ordering of elements within a
JSON object.

From the JSON specification at http://www.json.org/:

“An object is an unordered set of name/value pairs”

As a consequence, JSON libraries are free to rearrange the order of the elements as they see fit. This is not a bug.

Leave a Comment