In my entity I have:
private Set<Account> accounts;
Now it is being serialized like this:
"accounts": null
I need to change it to
"accounts": []
I have many (150+) entities which have this problem - how can configure jackson mapper to achieve this?
You could remove the "accounts" completely from the json annotating your pojo with:
@JsonInclude(JsonInclude.Include.NON_NULL)
maybe this helps
I think declaring your set like this will work...
private Set<Account> accounts = new HashSet<>();
It's then an empty set when marshalling and not null.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.