Inner object deserialization with Jackson

344 Views Asked by At

I have a json

{
"params": [
    {
        "key": "path",
        "options": {
            "string": {
                "prefix": "test_pref"
            }
        },
        "default": {
            "url": ""
        }
    }
]}

I have the following POJO class, where i want to map inner objects like option.string.prefix in json to prefix in Params POJO class.

@Data
@Accessors(chain = true)
public class Data {
    private List<Params> params;
}

@Data
@Accessors(chain = true)
public class Params {

    private String key;

    @JsonProperty("options.string.prefix")
    private String prefix;

    @JsonProperty("default.url")
    private String url;
}

Is there any Jackson annotation that helps me do this without @JsonProperty?

1

There are 1 best solutions below

0
On

The is @JsonGetter which is an alternative to @JsonProperty You can read a very nice article on the topic here: Jackson Annotation Examples