Conversation
|
[updated - a terrible mistake on my part!!!! - see code snippet below] Something like: By doing this, the current test cases will use the default implementation (no-ordering). @stleary and @johnjaylward I would say this pull request to be useful - YES, I do agree that as depicted in the JSON specification, ordering is irrelevant, BUT, there are a lot of cases where key order is relevant to business logic due to invalid (but unfortunately, unchangeable) implementations on how JSON data is returned by APIs. ...instead of... In the first case, if no ordering is preserved, the application will need to parse the key name just to process each "line" properly. This is an incorrect way to specify JSON, but there are a lot (a lot) of APIs being designed like this... unfortunately =_( |
|
There is no way we can accept this pr as is. It's been provided by many people nearly identically over the years. The best way to get this accepted would be to make a very thoughtful change like mentioned by @migueltt. Doing a thorough change while maintaining the current unordered logic as default would be the best way to get it accepted. |
|
Closed, for the reasons cited by @johnjaylward. Also added an entry to the Wiki FAQ page regarding how pull requests are evaluated: In this case, there are pull requests where @douglascrockford has responded to the question of JSONObject mapping. See for example #91 and #106. |
Yes, you have left a comment that you did that on purpose. So you will most likely deny this request.
I just love your JSON implementation! It's so intuitive and performs well.
The only thing that really annoys me is this "random" key order due to the HashMap.
LinkedHashMap stores key in the order they are inserted but still has super fast lookup.
JSON is very often also viewed by developers, so the order of the output keys should make sense.
Also, when you read a JSON string and then write it back to JSON again, the output is not mixed up but the same (not taking whitespace and differences in \u... character encoding into account).
If you deny the pull request, that will be fine.
I prefer the version with LinkedHashMap.