Questions tagged [jackson]

Jackson is a Java library for handling tasks like reading and writing (parsing / generating) and data binding to/from Java objects. Although primarily used for JSON, Jackson also supports many other data formats such as Avro, CBOR, CSV, Java Properties, Protobuf, Smile, XML and YAML.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
11 views

How to write a custom Deserialiser for Jackson to parse of a value that is either a String or an Object into a Java Class (oneOf)

Given this JSON documents: { "first-name": "John", "last-name": "Smith", "children": ["Sam", "Joe"] } or: { "first-...
Jmini's user avatar
  • 9,267
0 votes
1 answer
14 views

How to map a nested XML element content as a string of a map?

I'm using Java and Jackson: <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> <version>2....
Bằng Rikimaru's user avatar
0 votes
0 answers
22 views

How to get the SpringBoot (Jackson)-objectMapper in a debugger?

I would like some way to look at a json-string generated from an object I have in the debugger while on a breakpoint. There are alternatives that work but are not quite what I want: I know I can ...
julaine's user avatar
  • 515
0 votes
0 answers
15 views

Jackson JsonNode putPojo do not work for LocalDatetime

I am changing JSONObject to JsonNode in my project. It is easy to do with String or Primitive Type. However, when I attempt to put a pojo, especially the LocalDatetime property of it, it does not work....
Emiya Elien's user avatar
0 votes
1 answer
34 views

JsonNullable object is always has isPresent value = true

I have a file with a json format. It stores the json object that I use in my tests. I convert this file to an object using objectmapper and it converts fine, but there is one problem. All fields in ...
linkforget's user avatar
0 votes
0 answers
25 views

CustomPage class deserialization is not working with fiegn client

I have custompage class as follows @Getter @Setter @EqualsAndHashCode(callSuper = true) @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class ...
Divyansh Rajput's user avatar
0 votes
0 answers
21 views

Tomcat + jackson-databind => org.apache.tomcat.util.bcel.classfile.ClassFormatException

Having a primitive web application on Tomcat (9.0.63 or 10.1.16), try parsing the JSON and hence adding jackson-databind to pom.xml. <dependency> <groupId>com.fasterxml.jackson.core&...
Sergei Gots's user avatar
-1 votes
0 answers
37 views

The array object in the json string cannot be mapped to my pojo normally

I had some problems when writing my own yaml to** json rules**. I found that my array object would not successfully parse the object field I defined, but could not find the field, as shown below: name:...
DAHUANGGO's user avatar
0 votes
1 answer
34 views

Jackson: Is there a way to exclude everything by default in a class and include explicitly?

I have been messing about with Jackson for a while now and can't for the life of me figure out how to make Jackson only include the properties I tell it to. We have a setup with datamodels that ...
Lasse's user avatar
  • 1
0 votes
0 answers
56 views

JSON Response not holding field names of java object

I am parsing a 3rd party API Response into a custom class I made which seems to work fine. However, the JSON response from my own controller does not contain any field names of these objects. In code, ...
BitQueen's user avatar
  • 685
0 votes
1 answer
44 views

How to find the difference between two JSONs in java?

I have 2 large JSONs with nested elements and I need to find the difference of these jsons. Each Json represents the data from LDAP in different days. I was looking into Jackson's JsonNode class. ...
user1829449's user avatar
0 votes
0 answers
22 views

Spring boot jackson inheritance polymorphism with child class that has same parameters - how to tell jackson what class to use

I have an parent class EdgeEntity and a child class MigrationEdgeEntity extends EdgeEntity. Child does not have any new parameters. It's used for migration when some logic is altered/different then in ...
Jyri Ahia's user avatar
0 votes
2 answers
61 views

How do I deserialize to List of Strings or Boolean from an Object using Jackson?

I was previously using jackson-databind 2.8.11.3 + Java 8 to deserialise a class ApiRequest, which was used as a request body in an API call. It has worked fine all the while and the JSON string is ...
Zelda's user avatar
  • 21
0 votes
2 answers
54 views

Serialization of compiled Enum java

I have an enum that's taken from a compiled library I imported into my project. When an object containing this enum is sent as an api response it contains the enum constant, like: "attestation&...
IDK's user avatar
  • 361
0 votes
0 answers
25 views

Native Query with PostGIS Throws HttpMessageNotWritableException

I have two queries in my Spring Data JPA repository, one written in JPQL and another in native SQL. The JPQL query works flawlessly, while the native query throws a HttpMessageNotWritableException. ...
Simonas Petkevičius's user avatar
-1 votes
2 answers
34 views

Jackson annotation of deserialize Object property into JsonNode

This is a java model class used for calling REST API. The type of the property "value" is Object because the json is nested. public class request { public String id; public Object ...
user8024165's user avatar
0 votes
1 answer
37 views

Generated YAML file not being formatted as desired

I am attempting to generate a YAML file using the Jackson YAML library. I am seeking to create that file in a specific format, and am failing to do so. The data I am saving is a list of data test ...
Factor Three's user avatar
  • 2,124
-1 votes
1 answer
23 views

Java object to JSON conversion is giving extra attributes which is not present in java builder class

I am working on Java Object to JSON conversion using ObjectMapper but it is giving extra attribute which is not present in my java class. Below is the Java Object Builder class. @JsonDeserialize(...
Shahrukh Ali's user avatar
-1 votes
1 answer
46 views

Customise ObjectMapper to serialise LocalDateTime properly

I am using Spring Vault in my project and trying to store a serialised representation of LocalDateTime (ISO date time format) as a secret data in Vault. However, the ObjectMapper used inside Spring ...
adarshr's user avatar
  • 61.7k
1 vote
1 answer
55 views

Nested objects not being processed by `SerializerModifier` when class has custom Serializer (Jackson)

Okay, so I've built a functional custom BeanSerializer, which limits the depth of serialization, and I can use it as shown by creating a SerializerModifier and adding it to module. This WORKS great ...
Joshua Chambers's user avatar
-3 votes
0 answers
81 views

Java 17, jackson library - Avoid jackson for POJO to xml marshalling

Recently in my project, based on Spring framework, jackson library gets added, <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>...
SyAu's user avatar
  • 1,645
0 votes
3 answers
50 views

Jackson Not Throwing Custom Exception

I have the following field in my requisition @NotNull @JsonDeserialize(using = LocalDateDeserializer.class) @Schema(description = "BIRTH DATE", example = "1992-02-15") ...
Jossany Moura's user avatar
-1 votes
1 answer
85 views

Exception in thread "main" com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id

Im trying to use Jackson to store my app data as a Json using Jackson. Until now it was All right, but now I'm getting a strange error when I try to store an array of a class that have an object ...
Vinicius Candido's user avatar
2 votes
1 answer
65 views

Using Jackson with Optional to generate Optional.empty() when field is missing

I am using Jackson to convert a json string to java object. I have an Optional field in my class. Whenever I try to deserialize a string which is missing the optional field, it is generating null for ...
harsh pamnani's user avatar
0 votes
1 answer
51 views

Deserialization to a list of undefined generic type

I defined a class Person: public static class Person{ private String name; private String surname; // Getters, setters, contructor... } I run the following code: @Test public void ...
primož perušek's user avatar
2 votes
1 answer
83 views

Deserialize JSON created using custom getter and unwrapped object using Jackson

This is a follow up question of an answer to Jackson custom getters. The solution works and creates proper JSON. The problem is deserialization. I have an unwrapped object with some attributes not ...
Anho's user avatar
  • 169
0 votes
1 answer
45 views

Deserialize a JSON array to a data class or record

Given this JSON, ["answer", 42] and an accompanying class, data class JsonRow(val s: String, val n: Int) how can I use jackson to convert the array to the class? Minimal reproducible ...
Jake's user avatar
  • 425
0 votes
0 answers
20 views

Java object validation for dynamic object Hashmap?

We have a MQTT listener which receives messages which we need to validate syntactically. So we have one such object: Data Model: @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "&...
Siddharth Trikha's user avatar
2 votes
2 answers
163 views

ClassCastException when I use a list of objects in a POST API in Spring Boot

I want to create a simple REST API for a POST request in a Spring Boot project. For this POST request, I need to use this payload: [ { "name": "John", "user_name": &...
elvis's user avatar
  • 822
0 votes
0 answers
42 views

How to use latest SequencedSet interface (java21) with jackson?

I have a SequencedSet, but I can't find a way to make it work with jackson deserialization. I get this error InvalidDefinition Cannot find a deserializer for non-concrete Collection type [collection ...
Fundhor's user avatar
  • 3,399
0 votes
1 answer
29 views

How to configure Jackson to control the behaviour of null fields?

The class to which postman request body is mapped looks like this public class RequestBody { String firstName; String middleName; String lastName; } postman request body looks like this { "...
Ruturaj Dilip Mestry's user avatar
0 votes
0 answers
41 views

How to have the real application-produced response schema in springdoc-openapi?

I have a Spring Boot project using springdoc-openapi-starter-webmvc-ui to create an openapi-specification and show a Swagger UI. The project also uses Jackson to serialize data in JSON format. Jackson ...
Sebu's user avatar
  • 4,810
0 votes
0 answers
27 views

Adding certain json objects to a new JSON array converts decimals to strings

So I have this method that is being used to remove particular JSON objects from a JSON Array by taking in an input array and an index to remove as parameters. What is happening is that decimal values ...
Mayank Bhatia's user avatar
0 votes
3 answers
70 views

How can I skip fields of certain types during serialization?

I have a Spring AOP service which intercepts a lot of different third-party controllers endpoints. My service runs an endpoint, gets the result DTO, serialize DTO to json with ObjectMapper, sends json ...
Eugene_Z's user avatar
  • 243
0 votes
1 answer
27 views

Jackson kept using base class to de-serialize object in Java generic base class

Title Jackson failed to deserialize object in Java generic base class. Problem Description I'd like to de-serialize a JSON into an object in Java generic base class, but got exception: ...
bobyuan's user avatar
  • 370
0 votes
0 answers
38 views

Use module-based serialization in another codebase where I don't control ObjectMapper construction

I maintain a Scala library that successfully uses all the automatic jackson-module-scala functionality in its own home context, where I control the construction of ObjectMappers. Now, I'm trying to ...
Alex Cruise's user avatar
  • 7,959
-1 votes
0 answers
32 views

How to create customized (de-)serializer in Java Jackson that read/writes from multiple files?

I am trying to wrap my mind on the following: I want to use Jackson (de)serialize POJOs from multiple files - serializer would write a 'file per class'. The object that I am trying to serialize ...
Łukasz Wiecheć's user avatar
1 vote
1 answer
42 views

Parsing CSV with Jackson to POJO with nested POJO fields

Not A Duplicate: How to serialize nested collection of objects with Jackson My question was immediately closed after somebody left a comment within 49 seconds, so please don't continuously bot-close ...
pstatix's user avatar
  • 3,660
2 votes
0 answers
92 views

Occasional java.lang.VerifyError on application startup or workflow execution

In an application that has been stable for several months, we recently started seeing several cases where a java.lang.VerifyErroris being thrown, sometimes at application startup and sometimes during ...
Ram's user avatar
  • 1,117
0 votes
1 answer
25 views

How to make jsonIgnore be able to setvalue

Spring Boot 2.7.8 I have a simple POJO called participant. The front end sends an API request with the field IP which I want to store in the DB. However in the backend I am getting this field as null. ...
ksernow's user avatar
  • 662
0 votes
0 answers
21 views

ObjectMapperBean doesn't remove `is` of `is-getter` on Spring Boot 3.1

@JsonFormat(shape = JsonFormat.Shape.OBJECT) enum class TestEnumWithIsGetter( @get:JsonProperty("id") val id: Int, @get:JsonProperty("name") val label: String ...
jinseok.oh's user avatar
0 votes
1 answer
88 views

GSON JSON serialization - Unable to make field private int java.sql.Timestamp.nanos accessible

Since a recent Java upgrade we are failing to serialize an object read from a SQL database with values mapped to java.sql.Timestamp. The underlying database is a SAP Sybase and our customer was able ...
Felix's user avatar
  • 769
0 votes
1 answer
23 views

How to clone a json content with some modifications using jackson fasterxml

Suppose we create a json as a string constructed like this; StringWriter writer = new StringWriter(); final JsonGenerator json = mapper.getFactory().createJsonGenerator(writer); // construct the ...
Morpheus's user avatar
  • 1,722
0 votes
0 answers
48 views

How can I convert an Object to a JSON reperesentation using Spring Data REST outside of RestController?

I have a project based on Spring Data REST for providing an API to interact with a database. I am using also an EntityListener to handle the update callbacks to all the entities of the project. In ...
MickeyMouse's user avatar
-2 votes
1 answer
24 views

Spring boot ClassCastException to Jackson

I make simple Spring Boot app with MongoDB and face that issue in my controller class: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController' Caused ...
Olexie Polishchyk's user avatar
-1 votes
1 answer
37 views

Search JSON response to find and deserialize JSON object

I'm attempting to deserialize a JSON object with the Jackson objectMapper. The problem I'm having is that this target object can be wrapped in a variety of other JSON, including some but not all ...
Alex CC's user avatar
0 votes
0 answers
57 views

Why does Jackson not parse a JSON serialized with the same ObjectMapper?

I'm trying to serialize some big object with a lot of nested properties (a lot of them are polymorphic). As for now, I got a problem when trying to serialize an object that is basically an empty ...
k.meinkopf's user avatar
0 votes
2 answers
37 views

Deserializing enum with Jackson

I have a custom ApiException class that is used as a global model for exceptions thrown by REST controller. It looks as follows: @JsonIncludeProperties({"timestamp", "status", &...
IceMajor's user avatar
  • 162
0 votes
0 answers
24 views

jsonIgnore annotation is not working with Data annotation in lombok

I am trying to ignore some fields to be a part of REST template call. I am using lombok @Data and trying @JsonIgnore but I see JsonIgnored field in the request body. code sample: @Data @...
Hitesh Kumar's user avatar
0 votes
0 answers
22 views

Jackson xml serialization - how to write schema location

If I marshal java classes (generated through xjc from a xsd schema) using jaxb I correctly get this <Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.013.001.10" xmlns:xsi="http://...
Federico's user avatar

1
2 3 4 5
330