Closed GoogleCodeExporter closed 9 years ago
I couldn't reproduce this.
Map<String, Set<Long>> m = new HashMap<String, Set<Long>>();
m.put("a", new TreeSet<Long>(Arrays.asList(1L, 2L, 3L)));
m.put("b", new TreeSet<Long>(Arrays.asList(4L, 5L, 6L)));
String s = new Gson().toJson(m);
System.out.println(s);
Object value = new Gson().fromJson(s, new TypeToken<Map<String, Set<Long>>>() {}.getType());
System.out.println(value);
Original comment by limpbizkit
on 1 Oct 2011 at 5:10
Issue is string representation of "JSONObject.toString()" is different from the
"Gson().toString()". For example
Gson().toString() gives below output:
{"b":[4,5,6],"a":[1,2,3]}
JSONObject.toString() gives below output:
{"b":"[4, 5, 6]","a":"[1, 2, 3]"}
Code for reproducing the issue:
Map<String, Set<Long>> m = new HashMap<String, Set<Long>>();
m.put("a", new TreeSet<Long>(Arrays.asList(1L, 2L, 3L)));
m.put("b", new TreeSet<Long>(Arrays.asList(4L, 5L, 6L)));
JSONObject json = new JSONObject(m);
String s = json.toString();
System.out.println(s);
Object value = new Gson().fromJson(s, new TypeToken<Map<String, Set<Long>>>() {}.getType());
System.out.println(value);
Original comment by vinayasi...@gmail.com
on 2 Oct 2011 at 11:54
Original issue reported on code.google.com by
vinayasi...@gmail.com
on 16 Aug 2011 at 10:18