Skip to content
Advertisement

Tag: jackson

“org.springframework.data.util.TypeInformation.getActualType()” because “propertyType” is null

A Spring Boot 2.5.1 application is logging this warning: whereas Spring Boot 2.4.4 does not. The POJO is trivial: and the Spring RestController is similarly: To trigger the warning submit a POST: The warning is triggered while “handling” the _links property of the EntityModel<SoPojo> but why and what can I do about it. Any ideas? Update: As dkb notes, this

Jackson cannot parse body of a POST request

I am using Spring Boot to implement two web services, User and Book, and I am implementing the POST methods. When I send a POST request, i include the hard-coded JSON object in the HTTP Body: I am working at the same time on the two services, and while the creation of the “user” object works fine, Jackson throws an

Nested generic types in static method

I was trying to develop a generic method that could convert a JSON to a generic object that would have another instantiable generic object inside so I could use it as a parser in several places in my application. I had thought of the following solution, but it doesn’t work: Is there any way to be able to perform such

Serialize and Deserialize Java object having vavr list

I have a Java object with vavr list. When I serialize the object objectwriter.writeValueAsString(currentDossier) and print the values then in the JSON output I see, where remarks is a vavr list field inside the object. Now if I try to deserialize the same value into the object objectMapper.readValue(json, Customer.class) then I get error: Why is the seralized JSON text not

Adding custom arguments to Jackson deserializer

I have a custom deserializer. But I want to be able to pass additional arguments. For example How can I pass in my custom parameter on the annotation? Answer You cannot add your own parameters to @JsonDeserialize, because you can’t alter Jackson’s implementation of this annotation. However, you can achieve your goal in a slightly different way. You can invent

Deserialising JSON array using RestTemplate

I’m trying to convert JSON data to a java class using Rest Template. The JSON data has this format and cannot be changed: The java class to save the data is: To receive the JSON data and deserialize i’m doing: But i’m getting this exception: I’ve done this before and it worked, but the JSON data had a slightly different

ObjectMapper writeValueAsString on ‘null’ vs ‘NullNode.getInstance()’

Consider the following statements: String s1 = new ObjectMapper().writeValueAsString(null); String s2 = new ObjectMapper().writeValueAsString(NullNode.getInstance()); In both the cases, serialized values s1 and s2 would be “null” (in String format). Jackson, by default, serializes null objects without any exception. What are the cases where we need to use NullNode, instead of directly serializing null? Answer “null” here is a string, not

@JsonProperty not working after springboot upgrade

I recently upgraded my application from Spring Boot 1.5.3 to Spring Boot 2.3.5. One of the feature on UI started breaking and I found while debugging that the json response to UI had changed Original response: New response: having underscores (_) in attribute names It seems that the @JsonProperty is not working. My classes are as below: I tried @JsonCreator(mode

Advertisement