• Register
0 votes
6k 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
2 answers 211 views
211 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 2.2K views
2.2K 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 48 views
48 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 436 views
436 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 286 views
286 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 4.5K views
4.5K 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 10 views
10 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
0 votes
1 answer 747 views
747 views
Problem : I am implementing kerberos Authentication in my existing java spring application.My unix team has provided me SPN, krb5.conf and keytab file. I am trying hard but getting unable to obtain password from user exception
asked Oct 22, 2019 peterlaw 6.9k points
0 votes
2 answers 259 views
259 views
Problem : I am facing bellow error java.sql.sqlrecoverableexception no more data to read from socket
asked Nov 5, 2019 peterlaw 6.9k points
0 votes
2 answers 559 views
559 views
Problem : I am new to the Spring and JPA, wasted 10 days and no result with the searching on internet. I want to save the object to SQL SERVER, my connection is correct but when I write .flush() I get below exception &ldquo;nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress&rdquo;
asked Jan 21, 2020 jwilliam 3.9k points