All Questions

Tagged with
Filter by
Sorted by
Tagged with
130 votes
24 answers
189k views

java.lang.IllegalArgumentException: No converter found for return value of type

With this code @RequestMapping(value = "/bar/foo", method = RequestMethod.GET) public ResponseEntity<foo> foo() { Foo model; ... return ResponseEntity.ok(...
Marc's user avatar
  • 16.4k
125 votes
14 answers
228k views

How to customise the Jackson JSON mapper implicitly used by Spring Boot?

I'm using Spring Boot (1.2.1), in a similar fashion as in their Building a RESTful Web Service tutorial: @RestController public class EventController { @RequestMapping("/events/all") ...
Jonik's user avatar
  • 81k
118 votes
7 answers
187k views

JSON parse error: Can not construct instance of java.time.LocalDate: no String-argument constructor/factory method to deserialize from String value

I am new to Spring Data REST project and I am trying to create my first RESTful service. The task is simple, but I am stuck. I want to perform CRUD operations on a user data stored in an embedded ...
zavanton's user avatar
  • 1,454
65 votes
9 answers
124k views

ObjectMapper can't deserialize without default constructor after upgrade to Spring Boot 2

I have following DTOs: @Value public class PracticeResults { @NotNull Map<Long, Boolean> wordAnswers; } @Value public class ProfileMetaDto { @NotEmpty String name; @Email ...
solomkinmv's user avatar
  • 1,872
64 votes
9 answers
223k views

Deserialize Java 8 LocalDateTime with JacksonMapper

I have read several questions with answers here in SO concerning serialization and deserialization between java.time.LocalDateTime and JSON property but I can't seem to get it working. I have managed ...
Smajl's user avatar
  • 7,743
48 votes
5 answers
64k views

Jackson serializes a ZonedDateTime wrongly in Spring Boot

I have a simple application with Spring Boot and Jetty. I have a simple controller returning an object which has a Java 8 ZonedDateTime: public class Device { // ... private ZonedDateTime ...
jbx's user avatar
  • 21.8k
48 votes
11 answers
36k views

MockMvc no longer handles UTF-8 characters with Spring Boot 2.2.0.RELEASE

After I upgraded to the newly released 2.2.0.RELEASE version of Spring Boot some of my tests failed. It appears that the MediaType.APPLICATION_JSON_UTF8 has been deprecated and is no longer returned ...
times29's user avatar
  • 3,065
44 votes
5 answers
40k views

Lombok 1.18.0 and Jackson 2.9.6 not working together

The deserialization is failing after the update. I updated my micro-service from Spring 1.5.10.RELEASE to Spring 2.0.3.RELEASE and also updated the lombok from 1.16.14 to 1.18.0 and jackson-datatype-...
JHS's user avatar
  • 7,821
43 votes
1 answer
101k views

Cannot deserialize value of type `java.util.Date` from String

Using Spring 1.5.8.RELEASE Jackson mapper giving the following exception. Cannot deserialize value of type `java.util.Date` from String "2018-09-04T10:44:46": expected format "yyyy-MM-dd'T'HH:mm:ss....
Utkarsh Gandhi's user avatar
42 votes
3 answers
68k views

Deserialize a json array to objects using Jackson and WebClient

I have a problem during the deserialization of a json array using Spring. I have this json response from a service: [ { "symbol": "XRPETH", "orderId": 12122, "...
Justin's user avatar
  • 1,199
38 votes
8 answers
87k views

Jackson date-format for OffsetDateTime in Spring Boot

I'm trying to output an OffsetDateTime from my Spring application, and have in my application.properties these properties: spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false spring.jackson....
Dave's user avatar
  • 788
37 votes
6 answers
65k views

For Spring Boot 1.2.3, how to set ignore null value in JSON serialization?

In the Spring Boot 1.2.3, we can customize the Jackson ObjectMapper via properties file. But I didn't find a attribute can set Jackson ignore null value when serialization the Object to JSON string. ...
crisli's user avatar
  • 562
33 votes
5 answers
58k views

Jackson @JsonFormat set date with one day less

I have been used Spring Date Rest with Spring Boot in my project. This project has a object and I have used the annotation @JsonFormat to format the date field that will be received from my Json. The ...
William Miranda's user avatar
33 votes
2 answers
80k views

org.apache.catalina.connector.ClientAbortException: java.io.IOException: APR error: -32

At my Spring Boot + Tomcat 8 project I have configured @ControllerAdvice which looks like: @ControllerAdvice public class GlobalControllerExceptionHandler { final static Logger logger = ...
alexanoid's user avatar
  • 25k
30 votes
4 answers
56k views

Cannot construct instance of `java.time.LocalDate` - Spring boot, elasticseach, jackson

I'm using Spring-boot 2.0.0.M7 and spring-boot-starter-data-elasticsearch and elasticsearch 5 and I'm getting an error by deserializing a LocalDate field. My Document looks like that: @Document(...
Patrick's user avatar
  • 12.6k
29 votes
4 answers
69k views

How to make default time zone apply in Spring Boot Jackson Date serialization

I have configured my Spring Boot application to serialize dates as ISO8601 strings: spring: jackson: serialization: write-dates-as-timestamps: false This is what I am getting: "someDate"...
codependent's user avatar
  • 23.9k
26 votes
12 answers
29k views

How to configure Jackson ObjectMapper for Camel in Spring Boot

I am trying to serialize and deserialize POJOs to and from JSON on Camel routes using Jackson. Some of these have Java 8 LocalDate fields, and I want them to be serialised as YYYY-MM-DD string, not as ...
David Edwards's user avatar
25 votes
5 answers
37k views

openapi springboot generator jackson no String-argument constructor/factory method to deserialize from String value

I'm using OpenApi SpringBoot generator to generate controller interfaces and models. This creates model classes with JsonNullable<String> for nullable fields. However I'm getting a Jackson type ...
Dhanuj Dharmarajan's user avatar
25 votes
3 answers
110k views

JsonMappingException: Can not deserialize instance of java.lang.Integer out of START_OBJECT token

I wanted to write a small and simple REST service using Spring Boot. Here is the REST service code: @Async @RequestMapping(value = "/getuser", method = POST, consumes = "application/json", produces = ...
user2581426's user avatar
24 votes
3 answers
27k views

How to customise Jackson in Spring Boot 1.4

I've been unable to find examples of how to use Jackson2ObjectMapperBuilderCustomizer.java in spring boot 1.4 to customise the features of Jackson. The doco for customising Jackson in boot 1.4 - https:...
Reece's user avatar
  • 754
22 votes
1 answer
24k views

Validation nested models in spring boot

I have a problem with validation of nested models, look: class A{ @NotNull Integer i; B b; } class B{ @NotNull Integer j; } In spring controller: @Valid @RequestBody... It ...
user avatar
22 votes
1 answer
16k views

When does Jackson require no-arg constructor for deserialization?

In my spring boot project, I noticed a strange Jackson behavior. I searched over internet, found out what to do, but haven't found out why. UserDto: @Setter @Getter @AllArgsConstructor public class ...
ayfkly's user avatar
  • 271
22 votes
4 answers
14k views

Mapping query parameters to @ModelAttribute does not respect @JsonProperty name

@GetMapping("item") public @ResponseBody String get(@ModelAttribute Item item) Item has the attributes name itemType When I access /item?name=foo&item_type=bar the item gets populated only ...
hansi's user avatar
  • 2,278
22 votes
4 answers
31k views

Catching & Handling Jackson Exceptions with a custom message

I'm hoping to to catch some jackson exceptions that are occurring in a spring-boot API I am developing. For example, I have the following request class and I want to catch the error that occurs when ...
Funsaized's user avatar
  • 2,030
21 votes
3 answers
17k views

How to dynamically ignore a property on Jackson serialization

I have an entity with multiple @ManyToOne associations. I am using spring-boot to expose a REST API. Currently, I have multiple REST API's which return a JSON response of the whole entity, including ...
Achaius's user avatar
  • 6,054
21 votes
1 answer
37k views

How to Use Spring Boot's 'spring.jackson.date-format' Property?

According to the Current SpringBoot Reference Guide if I set the spring.jackson.date-format property, it will: Date format string or a fully-qualified date format class name. For instance 'yyyy-MM-dd ...
peterl's user avatar
  • 1,921
20 votes
1 answer
87k views

Jackson Converting String to Object

Link.java @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({ "rel", "href","method" }) public class Link { @JsonProperty("rel") private String rel; @JsonProperty("href") ...
ytibrewala's user avatar
  • 1,087
20 votes
3 answers
13k views

Stop Jackson from changing case of variable names

I am using Jackson in Spring to serialize my class to JSON. When I serialize a class like the example below, Jackson is changing the names of certain fields from Camel Case to lower case. I know I can ...
AnthonyW's user avatar
  • 1,949
19 votes
8 answers
32k views

Spring REST, JSON "Can not handle managed/back reference 'defaultReference'" 415 Unsupported Media Type

I am trying to POST to http://localhost:9095/translators from an AngularJS front-end using Spring boot/Spring RestController backend. I can do a GET and the response is like following: [{"userId":1,"...
senseiwu's user avatar
  • 5,149
19 votes
7 answers
21k views

Jackson is ignoring spring.jackson.properties in my spring boot application

Jackson is ignoring spring.jackson.property-naming-strategy=SNAKE_CASE. I am using springBootVersion 1.4.2.RELEASE. In my application.properties file, I have added spring.jackson.property-naming-...
so-random-dude's user avatar
19 votes
2 answers
37k views

Spring @RestController custom JSON deserializer

I want to use custom JSON deserializer for some classes(Role here) but I can't get it working. The custom deserializer just isn't called. I use Spring Boot 1.2. Deserializer: public class ...
jakub.petr's user avatar
  • 3,001
19 votes
5 answers
32k views

How to deserialize Joda DateTime using Jackson with Jersey 2 Client in Spring MVC?

I've been bashing my head with this proof of concept for a while. I want to consume a REST endpoint that returns JSON payload with an ISO8601 UTC timestamp: { ... "timestamp" : "2014-08-20T11:51:...
Reynaldo's user avatar
  • 680
19 votes
4 answers
19k views

Spring Boot: Wrapping JSON response in dynamic parent objects

I have a REST API specification that talks with back-end microservices, which return the following values: On "collections" responses (e.g. GET /users) : { users: [ { ... // ...
filpa's user avatar
  • 3,610
19 votes
2 answers
21k views

"Provider com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule not found" after Spring Boot Upgrade

I get this exception message after upgrading Spring Boot from 2.1.5 to 2.2.2, when I try to start the Application. Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error ...
Alexander Do's user avatar
18 votes
6 answers
32k views

Spring Boot 2.5.0 and InvalidDefinitionException: Java 8 date/time type `java.time.Instant` not supported by default

After update from Spring Boot 2.4.5 to Spring 2.5.0 I noticed the following exceptions in the application logs: Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/...
alexanoid's user avatar
  • 25k
18 votes
10 answers
65k views

Could not write JSON: failed to lazily initialize a collection of role

I tried to implement a REST service with Java, Hibernate, and Spring, which returns JSON. I have map a many to many relation. I have a supplier that has a list of ingredients, and each ingredient has ...
user avatar
18 votes
2 answers
31k views

Spring Boot - Encrypt JSON data

In our application we have to encrypt/decrypt the Json property values (not the property name) for each request and response. Example, {"userName":"encrypted value", "email":"encrypted value"} We ...
Raj's user avatar
  • 395
17 votes
1 answer
16k views

Spring WebFlux - ServerResponse Jackson Serializer problems

I have a problem during sending a HTTP GET request to my web server. Here is a snippet of code which is responsible for this resource: @GetMapping("/events") public Mono<ServerResponse> ...
Marcin Borowski's user avatar
17 votes
5 answers
42k views

org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'text/xml;charset=UTF-8' not supported for bodyType

using Java 11, SpringBoot 2, WebFlux, WebClient and Jackson trying to use Spring WebClient to consume a Web service endpoint that returns XML, content type: 'text/xml;charset=UTF-8' Jackson XML ...
guilhebl's user avatar
  • 8,690
16 votes
5 answers
25k views

spring boot Joda DateTime Serialisation

I'm trying to serialize Joda DateTime properties as ISO-8601 using Spring Boot v1.2.0.BUILD-SNAPSHOT Here is my very simple REST Application. @RestController @Configuration @ComponentScan @...
edge66's user avatar
  • 161
16 votes
2 answers
2k views

Lombok + Jackson immutables

After updating my project to Spring Boot 1.5.10 Lombok stopped working correctly with Jackson. I mean immutable DTOs creation, when field names in my objects are not same as fields in json request: @...
Rands7's user avatar
  • 161
15 votes
6 answers
16k views

Configure Jackson to omit lazy-loading attributes in Spring Boot

In spring boot mvc project with pure java configuration how to configure Jackson to omit lazy load Attributes
R K Punjal's user avatar
  • 1,465
15 votes
2 answers
33k views

How to rename json objects(variables) name in spring boot

Hello I am new to spring boot and JSON and need help in renaming the variable name coming in response. Consider this as a input "1": { "id": "1", "firstName": "Cdgdghirayu", ...
Chirayu Singhvi's user avatar
15 votes
3 answers
32k views

Spring Boot issues serializing java.time.LocalDateTime with Jackson to return ISO-8601 JSON timestamps?

I'm working on converting some models in a spring-boot REST API app to use java 8's java.time.LocalDateTime instead of joda's DateTime. I want the timestamps returned from API call to adhere to the ...
sa125's user avatar
  • 28.6k
15 votes
2 answers
16k views

How to configure Jackson in spring boot application without overriding springs default setting in pure java

In my spring boot application i am using Jackson to serialize objects by injecting the ObjectMapper where needed. I found this answer: https://stackoverflow.com/a/32842962/447426 But this one creates ...
dermoritz's user avatar
  • 12.9k
15 votes
1 answer
9k views

JSON parse error: Already had POJO for id

I already saw some question about this topic but i could not apply it to my case because I tried to apply them and the error continued. so I come to expose my situation. I read some comments about ...
Eduardo Krakhecke's user avatar
14 votes
1 answer
17k views

Setting Jackson feature WRITE_DATES_AS_TIMESTAMPS not working in Spring Boot

I set spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false in the Spring Boot config but the Jackson serializer still produces [1942,4,2] instead of "1942-04-02" for a DateTime value. Some ...
Marcel Stör's user avatar
  • 23.2k
14 votes
1 answer
6k views

How to map mock mvc GET call into java POJO?

I have a rest controller method that returns an object CompositeObject that contains within it several other objects and structures (Maps and Lists). I want to write a test that tests whether the rest ...
ITWorker's user avatar
  • 985
13 votes
2 answers
70k views

Spring Boot Automatic JSON to Object at Controller

I have SpringBoot application with that dependencies: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jersey</...
kamaci's user avatar
  • 73.9k
13 votes
3 answers
16k views

Alternatives for PropertyNamingStrategy.SNAKE_CASE or PropertyNamingStrategy.SnakeCaseStrategy as it is deprecated now

In prior versions of jackson, we were using the following two ways to modify the Property Naming during serialization and deserialization of objects. First way: Mentioning the following annotation on ...
Parundeep Singh's user avatar

1
2 3 4 5
39