Merge pull request #347 from ttulka/master

a comment added to explain the use of HashMap
This commit is contained in:
Sean Leary
2017-06-11 23:32:06 -05:00
committed by GitHub

View File

@@ -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>();
} }