Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ public String toString() {
* Construct an empty 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>();
}

Expand Down Expand Up @@ -216,15 +222,15 @@ public JSONObject(JSONTokener x) throws JSONException {
key = x.nextValue().toString();
}

// The key is followed by ':'.
// The key is followed by ':'.

c = x.nextClean();
if (c != ':') {
throw x.syntaxError("Expected a ':' after a key");
}
this.putOnce(key, x.nextValue());

// Pairs are separated by ','.
// Pairs are separated by ','.

switch (x.nextClean()) {
case ';':
Expand Down