Skip to content

Problem writing "empty" Map key (String with length 0) #30

@cowtowncoder

Description

@cowtowncoder

(problem reported by user via email)


Smile reader doesn’t do well with a map with an empty String key.

Map map = new HashMap();
map.put("foo", Collections.singletonMap("", "bar"));
ObjectMapper smileMapper = new ObjectMapper(new SmileFactory());
byte[] bytes = smileMapper.writer().writeValueAsBytes(map);
smileMapper.reader().readTree(new ByteArrayInputStream(bytes));

I get this exception:
Exception in thread "main" com.fasterxml.jackson.core.JsonParseException: Invalid shared name reference 2; only got 1 names in buffer (invalid content)
at [Source: java.io.ByteArrayInputStream@30c7da1e; line: -1, column: 12]


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions