Jackson: Mapping fields as key-value pair

When reading a JSON file, i would like to map my class as follows:

public class Effect {

private final String type;

private final Map parameters;

public Effect(String type, Map parameters) {

this.type = type;

this.parameters = parameters;

}

public String getType() {

return this.type;

}

public Map getParameters() {

return this.parameters;

}

}

 

{

"type": {

"key1": "value1",

"key2": "value2",

}

}

So, the mapped JSON object consists of type as the only key and parameters as its value.

I would like to use @JsonCreator on the constructor, but can't figure out, how to map the fields. Do i need to write a custom deserializer or...

Read More »

By: StackOverFlow - Friday, 13 April

Related Posts