boonproject / boon

Simple opinionated Java for the novice to expert level Java Programmer. Low Ceremony. High Productivity.
http://richardhightower.github.io/site/Boon/Welcome.html
Apache License 2.0
520 stars 102 forks source link

Parser changes order of elements alphabeticaly #375

Open ychyrski opened 7 years ago

ychyrski commented 7 years ago

Code example:

ObjectMapper mapper = JsonFactory.create();
Map<String, Object> input = ImmutableMap.of("s", "1", "d", "2", "a", "3", "f", new String[]{"7", "u", "5"});
String firstJson = mapper.toJson(input);
input = (Map<String, Object>)mapper.fromJson(firstJson);
String secondJson = JsonUtils.toJson(input);
Assert.assertEquals(secondJson, firstJson);

The reason is that internally either HashMap or SortedMap is being used (meaning implementation of <? implements ValueMap>) please consider add LinkingHashMap as a possible holder. Is there another way to prevent sorting?