I\'m building a RESTful API and want to provide developers with the option to choose which fields to return in the JSON response. This blog post shows examples of how sever
The Library jersey-entity-filtering Can do that :
https://github.com/jersey/jersey/tree/2.22.2/examples/entity-filtering-selectable
https://jersey.java.net/documentation/latest/entity-filtering.html
Exemple :
My Object
public class Address {
private String streetAddress;
private String region;
private PhoneNumber phoneNumber;
}
URL
people/1234?select=streetAddress,region
RETURN
{
"streetAddress": "2 square Tyson",
"region": "Texas"
}
Add to Maven
org.glassfish.jersey.ext
jersey-entity-filtering
2.22.2