• Register
0 votes
7.4k 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

Please log in or register to answer this question.

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
1 answer 30 views
30 views
Problem : Is there any annotation that needs to be added to be able to remove this issue: No string-argument constructor/factory method to deserialize from string value.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
2 answers 288 views
288 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 12 views
12 views
Problem: could anybody help me to fix this ? Could not extract response: no suitable httpmessageconverter found for response type.
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2.8K views
2.8K 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 16 views
16 views
Problem : I am trying to POST a List of custom objects but i am getting exception as below can not deserialize instance of java.util.arraylist out of start_object token
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 349 views
349 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, 2020 jwilliam 3.9k points
0 votes
1 answer 6K views
6K views
Problem : I am trying to POST a List of custom objects but i am getting exception as below can not deserialize instance of java.util.arraylist out of start_object token
asked Oct 22, 2019 peterlaw 6.9k points
0 votes
1 answer 67 views
67 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 659 views
659 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, 2020 mphil 2.3k points
0 votes
1 answer 16 views
16 views
Hello all! I&rsquo;m newbie programmer. Currently I&rsquo;m working with jSON to fetch some data for my new project.But I&rsquo;ve stucked with some problems. I&rsquo;m trying using getJSON method to get value of it. Need help. Any help will be appreciated. What I want to get is jobDescription&rsquo;s value. {"JobData":{"JobDescription":"Cashier Wanted","JobSearch":"Search"}}
asked Oct 27, 2020 mrain 120 points