File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,12 @@ public String toString() {
164164 * Construct an empty JSONObject.
165165 */
166166 public JSONObject () {
167+ // HashMap is used on purpose to ensure that elements are unordered by
168+ // the specification.
169+ // JSON tends to be a portable transfer format to allows the container
170+ // implementations to rearrange their items for a faster element
171+ // retrieval based on associative access.
172+ // Therefore, an implementation mustn't rely on the order of the item.
167173 this .map = new HashMap <String , Object >();
168174 }
169175
@@ -216,15 +222,15 @@ public JSONObject(JSONTokener x) throws JSONException {
216222 key = x .nextValue ().toString ();
217223 }
218224
219- // The key is followed by ':'.
225+ // The key is followed by ':'.
220226
221227 c = x .nextClean ();
222228 if (c != ':' ) {
223229 throw x .syntaxError ("Expected a ':' after a key" );
224230 }
225231 this .putOnce (key , x .nextValue ());
226232
227- // Pairs are separated by ','.
233+ // Pairs are separated by ','.
228234
229235 switch (x .nextClean ()) {
230236 case ';' :
You can’t perform that action at this time.
0 commit comments