Skip to content

Conversation

@johnscancella
Copy link

If you use a linkedHashMap instead of just hashMap you can easily make it ordered. I work on https://github.com/LibraryOfCongress/bagger which needs the JSONObject to preserve the ordering of the fields.

@erosb
Copy link
Contributor

The object ordering has already been discussed in #190 and has been rejected for 2 reasons:

  • the json specification says that objects are unordered, and this library shouldn't go against it
  • switching to LinkedHashMap would cause serious performance problems for larger objects, since the lookup (JSONObject.opt(key)) is expensive

@stleary
Copy link
Owner

Thanks, but can't accept this change. If you really need ordered JSONObjects, you might want to fork the project. A Library of Congress project sounds pretty cool, good luck!

@stlearystleary closed this Feb 18, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@johnscancella@erosb@stleary