Json parsing where a field can have two different types using gson or jackson

I have json with a field that contains two different types.

"fields":[{"value":"ZIELONE OKO"},{"value":{"@nil":"true"}}]

I have a problem with deserialization. My class with model contains:

private String value;

And I just need to translate {"@nil": "true"} to null. Now I get the error message:

The JsonDeserializer StringTypeAdapter failed to deserialized json object {"@nil":"true"} given the type class java.lang.String
+3
source share
1 answer

Ideally, I would change the code that creates this odd JSON: shouldn't the second value just be JSON null? I assume it is created by a complex process, starting with XML (which should use "isNul" to distinguish between a null string and an empty string).

, , , ; , . Map (, , ).

0

Source: https://habr.com/ru/post/1792788/


All Articles