我有这个代码:
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);
Run Code Online (Sandbox Code Playgroud)
personJson 就好像:
"id" : 1
Run Code Online (Sandbox Code Playgroud)
每当我Long type在我的Json中有一个,当我尝试阅读它时它不起作用.我有这个错误:
com.fasterxml.jackson.databind.JsonMappingException:无法从Integral编号实例化类型[simple type,class org.codehaus.jackson.generated.java.lang.Number]的值; 没有single-int-arg构造函数/工厂方法
我该如何让它接受这种类型Long?是否在映射器中启用了任何功能?
| 归档时间: |
|
| 查看次数: |
11971 次 |
| 最近记录: |