-2

My json requestBody is

{
    "action": "DONE",
    "email": {
        "29794": "sue@gmail.com",
        "29795": "sue@gmail.com"
    }
}

where "email" is a Map(key,value)pair and when i am deserializing this using the objectMapper.readvalue(entry.getValue(),List.class), I am getting the following exception:

com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'sue': was expecting ('true', 'false' or 'null')
 at [Source: (String)"sue@gmail.com"; line: 1, column: 4]

Please help where is it getting wrong.

Vishwa Ratna
  • 5,567
  • 5
  • 33
  • 55

2 Answers2

0

For such a simple mapping

HashMap<String,Object> result =
        new ObjectMapper().readValue(JSON_SOURCE, HashMap.class);

(where JSON_SOURCE is a File, input stream, reader, or json content String)

M Hamza Javed
  • 1,269
  • 4
  • 17
  • 31
0

Your input is Json Object which corresponds to Map and not List. So change your code

objectMapper.readvalue(entry.getValue(),List.class)

to

objectMapper.readvalue(entry.getValue(),Map.class)
Michael Gantman
  • 7,315
  • 2
  • 19
  • 36