• Register
0 votes
4.5k views

Problem :

I am running into the json parsing issue when using a ObjectMapper class from a com.fasterxml.jackson.databind package, and a error that I am getting is:

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 ('')

A web application where this problem is occurring is the Spring MVC application using an AngularJS front end, but I can duplicate a issue with the much smaller, all java program. 

Instead of sending values for the Address bean, I am getting just the empty string. Unfortunately, I am receiving the data from a third party and have no control over a data I receive.

Is there any annotation that needs to be added to be able to remove this issue?

7 5 2
3,870 points

1 Answer

0 votes

Solution :

You should try setting mapper.configure(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true)

Or you can try

mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);

It depends on the Jackson version.

OR

Had this issue in the recent past. Did lot of research on it and finally found the fix on the issue when I accidentally was calling the

mapper.convertValue(...)

instead of the

mapper.readValue(...)

So, you need to just make sure that you call correct method, since argument are same and IDE can find many things for you.

9 7 4
38,600 points

Related questions

0 votes
2 answers 161 views
161 views
Problem : I have created entities, services and JUnit tests for services using Spring and Hibernate for my project. All of these are working. After that I added spring-mvc to it to make this web application but while trying to make ... follows ..Could not autowire field: public pl.com.radzikowski.webmail.service.IMailManager pl.com.radzikowski.webmail.controller.HomeController.mailManager...
asked Nov 20, 2019 peterlaw 6.9k points
0 votes
1 answer 1.7K views
1.7K views
Problem : I am trying to use the curl command as follows: curl -u 591bf65f50057469f10b5fd9:0cf17f9b03d056ds0e11e48497e506a2 https://backend.tdk.com/api/devicetypes/59147fd79e93s12e61499ffe/messages But I am getting a JSON response as follows: {"data":[{"device":"18SE62"," ... T>, Object...) in the type RestTemplate is not applicable for the arguments (String, HttpEntity<String>,Class<MessageList>)
asked Dec 10, 2019 alecxe 7.5k points
0 votes
1 answer 247 views
247 views
Problem : I am very new to Spring Boot. I am learning to write code in Spring Boot. I have written my first Spring Boot code as below @RequestMapping(value = "/bar/foo", method = RequestMethod.GET) public MyResponseEntity<foo> foo() { Foo model; ... return ... .core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.3</version> </dependency> How can I fix above Spring Boot exception?
asked Feb 29 mphil 2.3k points
0 votes
1 answer 37 views
37 views
Problem : For many days I am trying to create Spring CRUD application but getting following error org.springframework.beans.factory.unsatisfieddependencyexception: error creating bean with name
asked Nov 13, 2019 peterlaw 6.9k points
0 votes
1 answer 216 views
216 views
Problem : I want to POST the List of custom objects. My JSON in a request body is as below : {     "collection": [         {             "name": "Test ordert1",             "detail": "ahk ksa"         },         {             "name": "Test ... } But I am facing below error: &ldquo;Can not deserialize instance of java.util.arraylist out of start_object token&rdquo; How can I fix the above error?
asked Jan 21 jwilliam 3.9k points