Issue 89 in json-simple: linkedHashMap does not preserve order once data has reached client

11 views
Skip to first unread message

json-...@googlecode.com

unread,
Sep 15, 2013, 8:27:07 PM9/15/13
to json-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 89 by multispe...@gmail.com: linkedHashMap does not preserve
order once data has reached client
http://code.google.com/p/json-simple/issues/detail?id=89

What steps will reproduce the problem?

1. put key value in linkedHashMap in a specific order
2. output json data on client in ajax response
3. order is not preserved

Map<String, String> obj=new LinkedHashMap<String, String>();
for (String id : runTimes.keySet()) {
obj.put(id, runTimes.get(id));
}
String jsonString = JSONValue.toJSONString(obj);

resp.setContentType("application/json; charset=utf-8");
PrintWriter out = resp.getWriter();
log.debug("pricing runtimes json: " +jsonString );
out.println(jsonString );
out.flush();
out.close();

expected:
pricing runtimes json: {"19":"09\/05\/2013 02:55 PM","18":"09\/05\/2013
02:09 PM","16":"08\/29\/2013 02:49 PM"}

What is the expected output? What do you see instead?
The order is out put correctly in java but when the json data is returned
to the client, the order has been resorted.

in ajax response:
Object {16: "08/29/2013 02:49 PM", 18: "09/05/2013 02:09 PM",
19: "09/05/2013 02:55 PM"}

What version of the product are you using? On what operating system?


Please provide any additional information below.


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages