mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-05 12:25:36 -04:00
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
This commit is contained in:
parent
ef7a5e40be
commit
d0f5607998
@ -164,6 +164,7 @@ public class JSONObject {
|
|||||||
* Construct an empty JSONObject.
|
* Construct an empty JSONObject.
|
||||||
*/
|
*/
|
||||||
public JSONObject() {
|
public JSONObject() {
|
||||||
|
// HashMap is used on purpose to ensure that elements are unordered
|
||||||
this.map = new HashMap<String, Object>();
|
this.map = new HashMap<String, Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +217,7 @@ public class JSONObject {
|
|||||||
key = x.nextValue().toString();
|
key = x.nextValue().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The key is followed by ':'.
|
// The key is followed by ':'.
|
||||||
|
|
||||||
c = x.nextClean();
|
c = x.nextClean();
|
||||||
if (c != ':') {
|
if (c != ':') {
|
||||||
@ -224,7 +225,7 @@ public class JSONObject {
|
|||||||
}
|
}
|
||||||
this.putOnce(key, x.nextValue());
|
this.putOnce(key, x.nextValue());
|
||||||
|
|
||||||
// Pairs are separated by ','.
|
// Pairs are separated by ','.
|
||||||
|
|
||||||
switch (x.nextClean()) {
|
switch (x.nextClean()) {
|
||||||
case ';':
|
case ';':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user