On Wed, Sep 5, 2018 at 9:28 PM Brexton Popejoy <[email protected]> wrote:
>
> I am writing a custom `StdDeserializer<RuleSet[]>` that will take a json with 
> the root node being an array and import it as an array of RuleSet objects. I 
> wrote most of the code for a single case (for importing just the first 
> ruleset from the json array, and I had no issues. However now that I've 
> changed it to import an array of rulesets, Jackson seems to be ignoring the 
> first array container given to it.
>
> I would guess that there is some built-in function to automatically loop 
> through a root array, however it is unclear how it is to be used, since I 
> have to return an array from my deserialize method. Any help on this?

By default deserializers are looked for elements, so `RuleSet` here:
If registering deserializers using `SimpleModule` only such value
deserializers can be registered, since normally deserializers (and
serializers) are composed from pieces. Otherwise one
would have to implement much larger sets (N, array of N, List of N,
Map of <x, N>).

But if you have some specific need to handle array case explicitly,
you need to implement `Module` yourself, override its `setupModule()`,
and register specific `Deserializers` implementation using
`context.addDeserializers(...)`.
`Deserializers` is the handler that gets called when ObjectMapper
needs to locate actual `JsonDeserializer`; for
array types callback method is `findArrayDeserializer(...)`.

-+ 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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to