#1157 - Fixed custom EntityModel serialization for Map payloads.
Using a custom serializer seems to break downstream projects that also register serializers for EntityModel. We're now using extra methods on EntityModel itself that do the trick as well.
This commit is contained in:
@@ -23,6 +23,7 @@ import java.util.Map;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
|
||||
@@ -80,6 +81,11 @@ public class EntityModel<T> extends RepresentationModel<EntityModel<T>> {
|
||||
|
||||
// Hacks to allow deserialization into an EntityModel<Map<String, Object>>
|
||||
|
||||
@JsonAnyGetter
|
||||
private Map<String, Object> getMapContent() {
|
||||
return Map.class.isInstance(content) ? (Map<String, Object>) content : null;
|
||||
}
|
||||
|
||||
@JsonAnySetter
|
||||
private void setPropertiesAsMap(String key, Object value) {
|
||||
getOrInitAsMap().put(key, value);
|
||||
|
||||
Reference in New Issue
Block a user