mirror of
https://github.com/ethauvin/JSON-java.git
synced 2025-06-17 07:50:52 -07:00
Merge pull request #347 from ttulka/master
a comment added to explain the use of HashMap
This commit is contained in:
commit
5b2e5e7579
1 changed files with 8 additions and 2 deletions
|
@ -164,6 +164,12 @@ 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 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>();
|
this.map = new HashMap<String, Object>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +222,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 +230,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…
Add table
Add a link
Reference in a new issue