org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type
org.codehaus.jackson.map.JsonMappingException: No suitable constructor found
for
type [simple type,
class
test.jackson.Employee]: can not instantiate from JSON object (need to add/enable type information?)
at [Source: c:\temp\employee.json; line:
1
, column:
2
]
at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:
163
)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:
483
)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:
350
)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:
2395
)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:
1549
)
at test.jackson.JSONToJavaExample.main(JSONToJavaExample.java:
19
)
一般来说,解决上面问题从下面几个方面入手:
1、是否缺少默认构造函数
2、是否是类的访问修饰符问题,即jackson访问不到。