Skip to content

Parser changes order of elements alphabeticaly #375

Description

@ychyrski

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?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions