2

I've a json string which must be converted as a Java map of Long and Object. When I tried with Jackson ObjectMapper it creates LinkedHashMap instances instead of Object

Json String

  "2": {
     "firstName": "test",
     "lastName": "test",
     "title": "test",
     "gender": "test",
        }
   }

Map<Long, Person> personMap = objectMapper.readValue(value, new TypeReference<Map<Long, Object>>(){});

I'm expecting a map of long and Person object

eHayik
  • 2,981
  • 1
  • 21
  • 33
Jijo
  • 107
  • 1
  • 1
  • 10
  • 1
    Possible duplicate of [Deserializing into a HashMap of custom objects with jackson](https://stackoverflow.com/questions/18002132/deserializing-into-a-hashmap-of-custom-objects-with-jackson). If you prefer `TypeReference`, use `new TypeReference>() {}`. – Michał Ziober Aug 08 '19 at 14:29

0 Answers0