From 753a8159980a303e217d66526db47dc6d22b076a Mon Sep 17 00:00:00 2001 From: Niels AD Date: Tue, 3 Apr 2012 14:23:51 +0200 Subject: [PATCH 1/2] HashMap to LinkedHashMap. --- JSONObject.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/JSONObject.java b/JSONObject.java index f8ee3590e..39adc5a8d 100755 --- a/JSONObject.java +++ b/JSONObject.java @@ -31,7 +31,7 @@ of this software and associated documentation files (the "Software"), to deal import java.lang.reflect.Method; import java.util.Collection; import java.util.Enumeration; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Iterator; import java.util.Locale; import java.util.Map; @@ -144,7 +144,7 @@ public String toString() { * Construct an empty JSONObject. */ public JSONObject() { - this.map = new HashMap(); + this.map = new LinkedHashMap(); } @@ -233,7 +233,7 @@ public JSONObject(JSONTokener x) throws JSONException { * @throws JSONException */ public JSONObject(Map map) { - this.map = new HashMap(); + this(); if (map != null) { Iterator i = map.entrySet().iterator(); while (i.hasNext()) { From 9b61b6ea6fc584aee9325aa3c0b33c77e0f0f3f0 Mon Sep 17 00:00:00 2001 From: Niels AD Date: Tue, 3 Apr 2012 15:10:34 +0200 Subject: [PATCH 2/2] TreeMap to ensure sorted list of properties in JSONObject. --- JSONObject.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JSONObject.java b/JSONObject.java index 39adc5a8d..3cc6dcba3 100755 --- a/JSONObject.java +++ b/JSONObject.java @@ -31,7 +31,7 @@ of this software and associated documentation files (the "Software"), to deal import java.lang.reflect.Method; import java.util.Collection; import java.util.Enumeration; -import java.util.LinkedHashMap; +import java.util.TreeMap; import java.util.Iterator; import java.util.Locale; import java.util.Map; @@ -144,7 +144,7 @@ public String toString() { * Construct an empty JSONObject. */ public JSONObject() { - this.map = new LinkedHashMap(); + this.map = new TreeMap(); }