On Tue, Dec 4, 2018 at 10:45 AM Pankaj Dighe <[email protected]>
wrote:

> I am trying to deserialize following JSON to map of <String, Object>
>
> String jsonString = "{\"personId\": 231, \"percentage\": 2.1212, \"name\": 
> \"Name\", " +
>         "\"activeDate\":\"26-09-2017 11:00:00\"}";
>
>
> I am trying to deserialize using following code:
>
> new 
> ObjectMapper()..configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
> false)
> .readValue(jsonString, new TypeReference<Map<String, Object>>() {});
>
>
> It works fine. The issue is I want the data type of every JSON property as
> String. E.g. In above jsonString : percentage is treated as Double I want
> this to be String.
>
> Can anyone please help me here?
>

Use TypeReference<Map<String, String>>() { } and values should be coerced
to Strings?

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

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