On Tue, Dec 4, 2018 at 12:27 PM Pankaj Dighe <pankajdigh...@gmail.com> 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"] } > > True, there is no way to coerce Arrays or Objects to Strings. If you want that, you will need to use some custom code. -+ Tatu +- > > On Tuesday, 4 December 2018 12:20:08 UTC-8, Tatu Saloranta wrote: >> >> On Tue, Dec 4, 2018 at 10:45 AM Pankaj Dighe <pankaj...@gmail.com> 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 jackson-user...@googlegroups.com. >>> To post to this group, send email to jackso...@googlegroups.com. >>> 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 jackson-user+unsubscr...@googlegroups.com. > To post to this group, send email to jackson-user@googlegroups.com. > 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 jackson-user+unsubscr...@googlegroups.com. To post to this group, send email to jackson-user@googlegroups.com. For more options, visit https://groups.google.com/d/optout.