I have this code:
final Person p = new Person(1L); final ObjectMapper mapper = JacksonUtil.INSTANCE.getMapper(); final TypeReference<HashMap<String, Object>> typeMap = new TypeReference<HashMap<String, Object>>() {}; final String personJson= mapper.writeValueAsString(p); mapper.readValue(personJson, typeMap);
personJson as follows:
"id" : 1
Whenever I have a Long type in my Json, it does not work when I try to read it. I have this error:
com.fasterxml.jackson.databind.JsonMappingException: Failed to instantiate a type value [simple type, class org.codehaus.jackson.generated.java.lang.Number] from an integer; no constructor / factory
How can I make it accept type Long ? Is there any function that needs to be enabled in the display device?
source share