Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkedHashMap does not preserve order once data has reached client #89

Open
GoogleCodeExporter opened this issue Dec 24, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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.

Original issue reported on code.google.com by [email protected] on 16 Sep 2013 at 12:26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant