estebangarcia / json-simple

Automatically exported from code.google.com/p/json-simple
Apache License 2.0
0 stars 0 forks source link

Order of JSON object elements not as expected #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Get source using svn
2. Import project into Eclipse
3. Run junit test on test/org.json.simple.Test.Java

What is the expected output? What do you see instead?
Expected:
{"array1":["abc\u0010a\/",123,222.123,true],"weight":60.21,"age":27,"name":"fang
","is_developer":true}
Instead:
{"age":27,"is_developer":true,"name":"fang","array1":["abc\u0010a\/",123,222.123
,true],"weight":60.21}

What version of the product are you using? On what operating system?
version: 1.1
OS: Windows 7 x64

Please provide any additional information below.
What is the expected ordering of the JSON object that is created?

Original issue reported on code.google.com by Grace.Ba...@gmail.com on 13 Jul 2010 at 1:09

GoogleCodeExporter commented 8 years ago
A JSON object is NOT guaranteed to be ordered according to JSON spec, but you 
can leverage some Java Map implementations to make ordered:

http://code.google.com/p/json-simple/wiki/EncodingExamples#Example_1-3_-_Encode_
a_JSON_object_-_Using_Map

Original comment by fangyid...@gmail.com on 13 Jul 2010 at 1:45