0

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?

Don_Quijote
  • 936
  • 3
  • 18
  • 27

2 Answers2

0

You could remove the "accounts" completely from the json annotating your pojo with:

@JsonInclude(JsonInclude.Include.NON_NULL)

maybe this helps

andgalf
  • 170
  • 10
0

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.

David Billings
  • 366
  • 2
  • 9