When you connect to an api and receive an object as an answer. What I used to do is create a pojo that matches the object, and than let de data be filled in. Sometimes the api provides hundreds of fields that I don't need, and I have to create giant pojos, with subpojos etc.. Apparently you can set up Spring Boot so that you only need to receive the part you want want. But I cannot seem to figure out how, nor can I find a tutorial somewhere where it is explained.
How can I set up Spring Boot so I can receive the JSON data from an api, but only the attributes I need, not the entire object?
I don't want to have to make an entire pojo like this:
class Receive {
attribute 1;
attribute 2;
attribute 3;
attribute 4;
attribute 5;
attribute 6;
//and so forth
}
but set it up so I only have to make what I need to receive, for example:
class Receive {
attribute 4;
attribute 10;
}
You can't do anything on the Server side but you can define in your model the fields you want to deal with and set on Class level following annotation(to ignore the rest of the fields )
@JsonIgnoreProperties(ignoreUnknown = true)