boonproject/boon

Parser changes order of elements alphabeticaly

Opened this issue · 0 comments

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?