I need to render objects in JSON and send them to the client but I need to exclude fields like email and password for obvious reasons.
I know play uses GSON (by google?) and you can pass a serializer class when calling the renderJSON() method. However I'm rendering different types of classes at once using a container class:
public class JSONContainer {
public List<User> userList;
public List<Toy> toyList;
}
For each class it's possible to make a Serializer class implementing GSON's JsonSerializer<...>
method. But if I render a JSONContainer object like this: renderJSON(container)
how can I pass the serializer classes to the rendering method?
Or is there maybe an easier/better way to do this?