On Fri, Dec 29, 2017 at 7:46 AM, J <[email protected]> wrote:
> Hi there,
>
> I was wondering if there is a specific way to convert a POJO to a nested map
> without tripping over the following error:
> "java.lang.IllegalArgumentException: Not a union.".

That does not sound like any exception am familiar with. Assuming this
is with JSON
(which does not have concept of union types)

> I've been trying with the following methods (w/ Jackson 2.2...maybe I should
> update), but both have not been fruitful:

Yes, 2.2 is obsolete and you should upgrade. Although I can not think
of specific problem
that could have applied here.

> ObjectMapper mapper = new ObjectMapper();
>
> // Convert POJO to Map
> Map<String, Object> map =
>     mapper.convertValue(foo, new TypeReference<Map<String, Object>>() {});
>
>
> Source:
> https://stackoverflow.com/questions/39543926/how-to-convert-pojo-to-map-and-vice-versa-in-java
>
>
>
> // object -> Map
>         Map<String, Object> map = oMapper.convertValue(obj, Map.class);
>         System.out.println(map);
>
> Source: https://www.mkyong.com/java/java-convert-object-to-map-example/
>

-+ 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