Skip to content

Commit

Permalink
comment added to explain the reason that JSON object is unordered
Browse files Browse the repository at this point in the history
to avoid implementators' misconceptions and tries to reimplement the
JSON object to keep the elements order
  • Loading branch information
ttulka committed Jun 9, 2017
1 parent d0f5607 commit 246350b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ public String toString() {
* Construct an empty JSONObject.
*/
public JSONObject() {
// HashMap is used on purpose to ensure that elements are unordered
// HashMap is used on purpose to ensure that elements are unordered by
// the specification.
// JSON tends to be a portable transfer format to allows the container
// implementations to rearrange their items for a faster element
// retrieval based on associative access.
// Therefore, an implementation mustn't rely on the order of the item.
this.map = new HashMap<String, Object>();
}

Expand Down

0 comments on commit 246350b

Please sign in to comment.