diff --git a/JSONObject.java b/JSONObject.java index 5ca5a45bc..4e724df6b 100755 --- a/JSONObject.java +++ b/JSONObject.java @@ -32,7 +32,7 @@ of this software and associated documentation files (the "Software"), to deal import java.lang.reflect.Modifier; 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; @@ -149,7 +149,7 @@ public String toString() { * Construct an empty JSONObject. */ public JSONObject() { - this.map = new HashMap(); + this.map = new LinkedHashMap(); } /** @@ -240,7 +240,7 @@ public JSONObject(JSONTokener x) throws JSONException { * @throws JSONException */ public JSONObject(Map map) { - this.map = new HashMap(); + this.map = new LinkedHashMap(); if (map != null) { Iterator i = map.entrySet().iterator(); while (i.hasNext()) { diff --git a/README b/README old mode 100755 new mode 100644 index b77c71a21..59a41b02c --- a/README +++ b/README @@ -1,3 +1,9 @@ +Note: +This implementation sort of breaks the JSON standard as it is based on +the JSON object being ordered. This package's existance is due to a bug in +SugarCRM 6.5 which forces you to use ordered JSON objects. + + JSON in Java [package org.json] Douglas Crockford @@ -9,15 +15,15 @@ douglas@crockford.com JSON is a light-weight, language independent, data interchange format. See http://www.JSON.org/ -The files in this package implement JSON encoders/decoders in Java. -It also includes the capability to convert between JSON and XML, HTTP -headers, Cookies, and CDL. +The files in this package implement JSON encoders/decoders in Java. +It also includes the capability to convert between JSON and XML, HTTP +headers, Cookies, and CDL. This is a reference implementation. There is a large number of JSON packages -in Java. Perhaps someday the Java community will standardize on one. Until +in Java. Perhaps someday the Java community will standardize on one. Until then, choose carefully. -The license includes this restriction: "The software shall be used for good, +The license includes this restriction: "The software shall be used for good, not evil." If your conscience cannot live with that, then choose a different package. @@ -29,7 +35,7 @@ to produce a map-like object. The object provides methods for manipulating its contents, and for producing a JSON compliant object serialization. JSONArray.java: The JSONObject can parse text from a String or a JSONTokener -to produce a vector-like object. The object provides methods for manipulating +to produce a vector-like object. The object provides methods for manipulating its contents, and for producing a JSON compliant array serialization. JSONTokener.java: The JSONTokener breaks a text into a sequence of individual @@ -39,15 +45,15 @@ JSONException.java: The JSONException is the standard exception type thrown by this package. -JSONString.java: The JSONString interface requires a toJSONString method, +JSONString.java: The JSONString interface requires a toJSONString method, allowing an object to provide its own serialization. -JSONStringer.java: The JSONStringer provides a convenient facility for +JSONStringer.java: The JSONStringer provides a convenient facility for building JSON strings. -JSONWriter.java: The JSONWriter provides a convenient facility for building +JSONWriter.java: The JSONWriter provides a convenient facility for building JSON text through a writer. - + CDL.java: CDL provides support for converting between JSON and comma delimited lists. diff --git a/org.json.jar b/org.json.jar new file mode 100644 index 000000000..9e548f806 Binary files /dev/null and b/org.json.jar differ