how to parse some field of json spring boot

ankit

I have json with following fields:

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

But i want only country and id to deserialize in spring boot with fasterxml.jackson.

AKA

You can use @JsonIgnoreProperties( ignoreUnknown = true ) in you DTO:

@Data
@JsonInclude( JsonInclude.Include.NON_NULL )
@JsonIgnoreProperties( ignoreUnknown = true )
public class ProductVO
{
    private String id;
    @JsonProperty( "country" )
    private double country;
}

Hope this will help you in spring boot.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to parse json in Spring Boot and write to a repository

Unable to parse JSON in spring boot

How to parse JSON in Spring Boot Application automatically using Jackson

How to send some specific info in Header and some info in Body in a single JSON response, for a GET request in Spring boot?

Spring Boot include ID field in json

How to parse a Json response and store some attributes

How to parse a JSON and delete some elements

How to parse only 1 variable from JSON HTTP response Spring Boot

How to disable some warnings in Spring Boot

How to parse an inner field in a nested JSON object

How to parse JSON and get only one field?

How to parse JSON from input field

How to allow a field to be blank in spring boot?

How to not serialize @Id field in Spring Boot @RestController?

How Field Injection in Spring Boot works internally?

how to validate with regex input field in spring boot

Spring Boot web cannot parse nested json to object

Json Parse Error - MismatchedInputException expecting array or string for LocalDate in Spring Boot

spring boot mongodb json parse string as a date error

Spring Boot JSON parse error: Cannot construct instance of model

Some error with parse json

Spring, JSON serializer, serialize a field only in some cases

Best way to load some JSON files into a Spring Boot application

why is spring boot returning me a json with null for some values?

How to add a count field in spring data jpa and spring boot with join

Spring boot jpa / hibernate wrong column type encounter (json field)

HttpMessageNotReadableException: Could not read JSON: Unrecognized field using Spring boot and Android

Kotlin + Spring Boot default value for Int field from JSON

Dynamically change field's key name in JSON using spring boot