简体   繁体   English

内部 object 反序列化与 Jackson

[英]Inner object deserialization with Jackson

I have a json我有一个 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.我有以下 POJO class,我想要 map 内部对象,如 json 中的 option.string.prefix 到 Params POJOB642F2A29EBDC02 中的前缀。

@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?是否有任何 Jackson 注释可以帮助我在没有@JsonProperty 的情况下做到这一点?

The is @JsonGetter which is an alternative to @JsonProperty You can read a very nice article on the topic here: Jackson Annotation Examples这是@JsonGetter ,它是@JsonProperty的替代品。您可以在此处阅读有关该主题的非常好的文章: Jackson 注释示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM