Spring boot 如何解析json spring boot的某些字段

Spring boot 如何解析json spring boot的某些字段,spring-boot,jackson,Spring Boot,Jackson,我有以下字段的json: { "id": "MSNVK13LWEWV91", "country": "india", "name": "cooktop test products", "id_brand": "7fbdea31-a2bf-437b-8697-72edfb7fe673", "product_type": "visible" }

我有以下字段的json:

       {
            "id": "MSNVK13LWEWV91",
            "country": "india",
            "name": "cooktop test products",
            "id_brand": "7fbdea31-a2bf-437b-8697-72edfb7fe673",  
            "product_type": "visible"
        }

但我只希望在spring boot中使用fasterxml.jackson反序列化国家/地区和id。

您可以在DTO中使用
@JsonIgnoreProperties(ignoreUnknown=true)

@Data
@JsonInclude( JsonInclude.Include.NON_NULL )
@JsonIgnoreProperties( ignoreUnknown = true )
public class ProductVO
{
    private String id;
    @JsonProperty( "country" )
    private double country;
}
希望这将有助于您在春季开机