-
Notifications
You must be signed in to change notification settings - Fork 474
Closed
Labels
Milestone
Description
spring-hateoas version: 1.2.0-SNAPSHOT
When the content is a Map
in EntityModel
, it is not getting converted in proper JSON
. The content is getting duplicated.
Test case to describe this behavior:
@Test
public void testSerializationOfMap() throws JsonProcessingException {
final Map map = new HashMap();
map.put("key", "value");
final String serialized = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(EntityModel.of(map));
System.out.println("Incorrect representation, key value are duplicating at root level as well as under content");
System.out.println(serialized);
class KeyValue {
public KeyValue(String value) {
key = value;
}
public String key;
}
KeyValue keyValue = new KeyValue("value");
final String serializedKeyValue = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(EntityModel.of(keyValue));
System.out.println("Correct representation when using custom class KeyValue");
System.out.println(serializedKeyValue);
}