You can also deserialize as JsonNode:

JsonNode json = new ObjectMapper.readValue(jsonString, JsonNode.class);

That will take care of the Json array, you can iterate property by property 
and ask if *isJsonArray()* or something like that.
You can also read each value *asText()* which will give you a string

Hope that helps,
Guido.

On Tuesday, December 4, 2018 at 8:27:44 PM UTC, Pankaj Dighe wrote:
>
> Thanks for the response. Using TypeReference<Map<String, String>>() { } 
> works fine when I have following json
>
> String jsonString = "{\"personId\": 231, \"percentage\": 2.1212, \"name\": 
> \"Name\", " +
>         "\"activeDate\":\"26-09-2017 11:00:00\"}";
>
>
> but does not work when I have nested json objects. E.g. : {"a":"b", "c":{
>
> "d":"1"}, "z":["1"] }
>
>
> On Tuesday, 4 December 2018 12:20:08 UTC-8, Tatu Saloranta wrote:
>>
>> 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