From d0f560799820df4237c33417ce7765eafc9556d4 Mon Sep 17 00:00:00 2001 From: Tomas Tulka Date: Thu, 8 Jun 2017 08:03:14 +0200 Subject: [PATCH] a comment added to explain the use of HashMap to avoid misconception of contributors about using HashMap to implement a JSON object as a unordered collection by the definition --- JSONObject.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/JSONObject.java b/JSONObject.java index ff4acfa..f974430 100644 --- a/JSONObject.java +++ b/JSONObject.java @@ -164,6 +164,7 @@ public class JSONObject { * Construct an empty JSONObject. */ public JSONObject() { + // HashMap is used on purpose to ensure that elements are unordered this.map = new HashMap(); } @@ -216,7 +217,7 @@ public class JSONObject { key = x.nextValue().toString(); } -// The key is followed by ':'. + // The key is followed by ':'. c = x.nextClean(); if (c != ':') { @@ -224,7 +225,7 @@ public class JSONObject { } this.putOnce(key, x.nextValue()); -// Pairs are separated by ','. + // Pairs are separated by ','. switch (x.nextClean()) { case ';':