X Tutup
Skip to content
Closed
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 @@ -38,6 +38,8 @@ of this software and associated documentation files (the "Software"), to deal
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;

/**
* A JSONObject is an unordered collection of name/value pairs. Its external
Expand Down Expand Up @@ -240,7 +242,11 @@ public JSONObject(JSONTokener x) throws JSONException {
* @throws JSONException
*/
public JSONObject(Map map) {
this.map = new HashMap();
if (map instanceof SortedMap) {
this.map = new TreeMap(map);
} else {
this.map = new HashMap();
}
if (map != null) {
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
Expand All @@ -252,7 +258,7 @@ public JSONObject(Map map) {
}
}
}

/**
* Construct a JSONObject from an Object using bean getters. It reflects on
* all of the public methods of the object. For each of the methods with no
Expand Down
X Tutup