. Advertisement .
..3..
. Advertisement .
..4..
I get the error as follow when I tried to run into a json parsing issue and use the class of ObjectMapper from the package of com.fasterxml.jackson.databind
com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.graybar.utilities.ups.beans.Address: no String-argument constructor/factory method to deserialize from String value (”)
The web application on which this issue is happening is one that is a Spring MVC application with an AngularJS front-end. However, I’ve been able to reproduce the issue using a smaller, all-java application. Below are the beans I used: Shipment.java; Activity.java; ActivityLocation.java; Address.java The code to map the json get back and when adjusting the jsonMessage
var data. But, the problem occurs when adjusting the json, it is from:
{
"ActivityLocation": {
"Address": {
"City": "Honolulu",
"StateProvinceCode": "Hi",
"CountryCode": "US"
}
}
}]
to
{
"ActivityLocation": {
"Address": ""
}
}
help me to solve this problem, thanks
To address: no string argument constructor factory method to deserialize from string value, it also depend of the Jackson version in your system but just try this way:
mapper.configure( DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)
and other solution:
mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
I think you just check the corect solution to call it. This happened when calling this:
instead,