Java 如何使用特定字段将json转换为pojo

Java 如何使用特定字段将json转换为pojo,java,json,jackson,Java,Json,Jackson,我尝试将这个json(这是来自google people api的响应)转换为pojo。我得到的是null,而不是包含数据的对象。我认为我的pojo是不正确的,杰克逊无法转换它 { "resourceName": "people/113175645456469629209", "etag": "%EgoBAj0DBgk+NTcuGgQBAgnfvtrUH", "names": [ {

我尝试将这个json(这是来自google people api的响应)转换为pojo。我得到的是null,而不是包含数据的对象。我认为我的pojo是不正确的,杰克逊无法转换它

{
"resourceName": "people/113175645456469629209",
"etag": "%EgoBAj0DBgk+NTcuGgQBAgnfvtrUH",
"names": [
    {
        "metadata": {
            "primary": true,
            "source": {
                "type": "PROFILE",
                "id": "113175645456469629209"
            }
        },
        "displayName": "firstName lastName",
        "familyName": "lastName",
        "givenName": "firstName",
        "displayNameLastFirst": "firstName, lastName",
        "unstructuredName": "firstName, lastName"
    }
]
}
我只想得到名和姓的pojo

import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.social.google.api.plus.Person;

public class CustomPerson {

    @JsonProperty("names")
    private CustomPerson.Names names;

    public CustomPerson() {
    }

    public String getGivenName() {
        return this.names == null ? null : this.names.givenName;
    }

    public String getFamilyName() {
        return this.names == null ? null : this.names.familyName;
    }

    private static class Names {
        @JsonProperty
        private String givenName;
        @JsonProperty
        private String familyName;

        private Names() {
        }
    }
}
任何建议都会对我有所帮助{
public class CustomPerson {

    @JsonProperty
    private List<CustomPerson.Names> names;

    public CustomPerson() {
    }

    private static class Names {
        @JsonProperty
        private String givenName;
        @JsonProperty
        private String familyName;

        private Names() {
        }

        public String getGivenName() {
            return this.names == null ? null : this.names.givenName;
        }

        public String getFamilyName() {
            return this.names == null ? null : this.names.familyName;
        }
    }
}
@JsonProperty 私人名单名称; 公众人士(){ } 私有静态类名{ @JsonProperty 私人字符串givenName; @JsonProperty 私有字符串familyName; 私人姓名(){ } 公共字符串getGivenName(){ 返回this.names==null?null:this.names.givenName; } 公共字符串getFamilyName(){ 返回this.names==null?null:this.names.familyName; } } }