如何使用@JsonProperty检索子属性?

时间:2015-11-05 19:21:01

标签: java json

我有艺术家Joseph Turner的以下元数据:

{
    "activePlaceCount":0,
    "birth":{
        "place":{
            "name":"London, United Kingdom",
            "placeName":"London",
            "placeType":"inhabited_place"
         },
        "time":{
            "startYear":1775
        }
    },
    "birthYear":1775,
    "date":"1775\u20131851",
    "death":{
        "place":{
            "name":"Chelsea, United Kingdom",
            "placeName":"Chelsea",
            "placeType":"neighbourhood"
        },
        "time":{
            "startYear":1851
        }
    },
    "fc":"Joseph Mallord William Turner",
    "gender":"Male",
    "id":558,
    "mda":"Turner, Joseph Mallord William",
    "movements":[
        {
            "era":{
                "id":290,
                "name":"18th century"
            },
            "id":345,
            "name":"Picturesque"
        },
        {
            "era":{
                "id":350,
                "name":"19th century"
            },
            "id":364,
            "name":"Romanticism"
        },
        {
            "era":{
                "id":290,
                "name":"18th century"
            },
            "id":349,
            "name":"Sublime"
        }
    ],
    "startLetter":"T",
    "totalWorks":41861,
    "url":"http://www.tate.org.uk/art/artists/joseph-mallord-william-turner-558"
}

如果我想在我的Java程序中将fc映射到firstName,我可以简单地执行以下操作:

@JsonProperty("fc")
private String fullName;

那,或private String fc

如果想要检索"death"."time"."startYear",我会怎么做?

1 个答案:

答案 0 :(得分:1)

基于this SO answer,目前无法创建此类注释,但它是未来的门票(Java的更新)。