On Tue, Jul 16, 2019 at 6:17 PM Nicola Delbono <[email protected]> wrote:
>
>
> Hello,
> I can't figure out how to deserialize the following structure.
>
>
> "years":{
> "2019":{ /* contains "week" objects */ },
> "2020":{ /* contains "week" objects */ },
> "2021":{ /* contains "week" objects */ }
> },
>
>
> The mappers keeps saying
>
> com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
> Unrecognized field "2019"
>
> It looks for properties named after the years which is obviously not possible.
>
> I tried
>
> public Map<String,Week> year;
>
> and other variations but none worked.
>
>
> Can someone point me to the right directions? (with an example maybe)
>
> I'm stuck with this probably simple issue.
That should work in some form, but I suspect you have some structural mismatch.
Assuming json is like:
{
"years":{
"2019":{ /* contains "week" objects */ }
}
}
then it would map to POJO
public class Stuff {
public Map<String, Week> years;
}
-+ Tatu +-
--
You received this message because you are subscribed to the Google Groups
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jackson-user/CAL4a10h2jsgHAj0VAoJnyHht6z6twxosf8_t%2Brmc0D%3DOJw93hw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.