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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions