You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered an issue with org.json.JSONObject where the order of key-value pairs is not preserved when constructing JSON objects. This is problematic for my use case, as the frontend relies on the specific order of the data.
After examining the source code, I noticed that org.json.JSONObject uses HashMap internally, which does not maintain the insertion order of keys. I have two main questions regarding this issue:
Preservation of Insertion Order: Are there any strategies or plans to ensure the insertion order of key-value pairs in org.json.JSONObject?
Design Philosophy: What was the rationale behind using HashMap for org.json.JSONObject, given that it doesn't preserve order? Is there an intention to support ordered JSON in future versions of the library?
Thank you for your attention to this matter.
The text was updated successfully, but these errors were encountered:
Are there any strategies or plans to ensure the insertion order of key-value pairs in org.json.JSONObject?
No
What was the rationale behind using HashMap for org.json.JSONObject, given that it doesn't preserve order?
This project follows the JSON spec, which states that,
"An object is an unordered collection of zero or more name/value pairs, where a name is a string and a value is a string, number, boolean, null, object, or array."
Is there an intention to support ordered JSON in future versions of the library?
No
This is a frequent question, so I am keeping issue #822 open for discussion. You can continue making your case there, if you want. Otherwise, your best bet is to fork the repository and implement support for ordering yourself, or use a more permissive library.
Hi,
I've encountered an issue with org.json.JSONObject where the order of key-value pairs is not preserved when constructing JSON objects. This is problematic for my use case, as the frontend relies on the specific order of the data.
After examining the source code, I noticed that org.json.JSONObject uses HashMap internally, which does not maintain the insertion order of keys. I have two main questions regarding this issue:
Preservation of Insertion Order: Are there any strategies or plans to ensure the insertion order of key-value pairs in org.json.JSONObject?
Design Philosophy: What was the rationale behind using HashMap for org.json.JSONObject, given that it doesn't preserve order? Is there an intention to support ordered JSON in future versions of the library?
Thank you for your attention to this matter.
The text was updated successfully, but these errors were encountered: