Objectmapper json to object error handling

Source: Internet
Author: User

When using Objectmapper to convert the JSON to an object, call Mapper.readvalue (Jsonstr, Xwjuser.class), report the following error:

Com.fasterxml.jackson.databind.JsonMappingException:Can not construct instance of entity. Xwjuser:no suitable constructor found, can not deserialize fromObject Value (missingdefaultconstructor or creator, or perhaps need to add/enable type information?) at [Source: {"ID":1,"message":"Hello World","Sendtime":1525162183195,"intlist":NULL}; Line1, column:2] at com.fasterxml.jackson.databind.JsonMappingException. from(Jsonmappingexception.java:261) at Com.fasterxml.jackson.databind.DeserializationContext.instantiationException ( Deserializationcontext.java:1456) at Com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator ( Deserializationcontext.java:1012) at Com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault ( Beandeserializerbase.java:1203) at Com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject (Beandeserializer.java:314) at Com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize (Beandeserializer.java:148) at Com.fasterxml.jackson.databind.objectmapper._readmapandclose (Objectmapper.java:3789) at Com.fasterxml.jackson.databind.ObjectMapper.readValue (Objectmapper.java:2833) at TESTJSON.TESTOBJECTMAPPER.TESTOBJ (Testobjectmapper.java: -) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
....

Workaround: In the Xwjuser entity class, add the parameterless constructor, you can solve

Objectmapper json to object error handling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.