I'm using Jackson to read/write data from/into JSON files and I have an issue with the User POJO. It has a Map<Enum, Object> which is supposed to be the ways to contact the User (so it can have from 0 to 7, depending on the Enum). I want to be able to put ways to contact using a form in JSF.
I tried something like value="#{config.user.contacts[EMAIL_PRO]}"
where of course EMAIL_PRO is an Enum (later, the user should be able to chose the Enum himself, but right now I try simple).
But when I do so, the error is
Null key for a Map not allowed in JSON
which I understand, 'cause my debug says that the value returned is {null = null}
. Now first question: since the map is empty, is JSF supposed to work simply like that? The key "EMAIL_PRO" doesn't exists yet, but shouldn't JSF make the work done for me, and put right value with the key?
The other question is much more about Jackson and Maps. As I said, my POJO User contains a Map, and the JSON file is a Map himself (containing multiple users).
Is it really possible to write a Map into this file using Jackson where the Map is Map<String, Object>
and the Object contains a Map<Enum, Object>
? And if yes, how?
Thanks for the help
PS: I cannot change either my APIs or my POJOs.