playframework - Use @JsonView to exclude (like @JsonIgnore) with play frameworks default json writer? -


It seems that you can not join @JsonIgnore and @JsonView. I want to hide a field by default, but show it in some cases.

Actually I've got this setup: -

  Expands class parent model {public long id; Public child child; } Class Child Model {Public Long Id; @JasonView (full class) public string secret; Public stable class full {}; }  

and play.libs.Json.toJson (parent) to render without child.secret, and

< Pre>

To render with the child. Secret Is there any way of doing it. That is, there is a way to set a field to ignore by default, but can it be included with a special JasonView?

At this time both calls include the secret.

Thank you!

Once you create an object mapper, you can use it effectively As you are currently using play

So whenever you were using play.libs.Json.toJson (parent) first , just use the new ObjectMapper (). WriteValueAsString () and you will not get your secret.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -