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.

Jackson is a Java serialization and deserialization API typically used for reading and writing JSON, although other data formats such as Avro, CBOR, CSV, Java Properties, Protobuf, Smile, XML, and YAML are also supported. It offers multiple processing modes including "streaming", "data-binding" and "tree model"; of these, latter two builds on streaming processing.

The Jackson homepage is hosted on GitHub, and the project's Wiki is here.

Alternatives

Alternative Java-to-JSON binding solutions with similar APIs include FastJSON, Google Gson, and svenson. Yet more Java-to-JSON libraries are listed at json.org.

Performance

The latest performance benchmarks for these and other JSON serialization and deserialization solutions for Java are available online.

16401 questions
7
votes
1 answer

Set a different ObjectMapper for certain package Spring MVC

Is there a way to set a HttpMessageConverter for only certain packages in my project using spring? @Configuration @EnableWebMvc @ComponentScan(basePackageClasses = MyConfig.class) public class MyConfig extends WebMvcConfigurerAdapter { …
nachokk
  • 14,363
  • 4
  • 24
  • 53
7
votes
1 answer

Jackson Unmarshall custom object instead of LinkedHashMap

I have a Java object Results: public class MetaData { private List> properties private String name ... ... getters/setters ... } The AttributeValue class is a generic key-value class. It's possible…
heisa
  • 834
  • 1
  • 9
  • 17
7
votes
2 answers

Can not deserialize instance of java.lang.Class out of START_OBJECT token

I can't understand propperly the error I get when I run this code: InputStream is = this.getClass().getClassLoader().getResourceAsStream(filename); String jsonTxt = IOUtils.toString(is); JSONArray json = (JSONArray)…
Blanca Hdez
  • 3,513
  • 19
  • 71
  • 93
7
votes
3 answers

Jackson serialise map with extra fields

If a class extends a Map and includes some extra fields. E.G a last modified date, Jackson seems to ignore any thing not contained as a property of the map. I have a class that looks some thing like the following: import java.io.IOException; import…
Wil Selwood
  • 1,112
  • 2
  • 11
  • 19
7
votes
1 answer

How to set a custom Jackson ObjectMapper for Jersey 1.0 client

I am using Jersey 1.0 http-client to call a resource and deserialize the response JSON like this: Client client = Client.create(new DefaultClientConfig()) ClientResponse clientResponse =…
woezelmann
  • 1,355
  • 2
  • 19
  • 39
7
votes
3 answers

Get specific value while parsing JSON with Jackson

I have the following JSON: [ { "A":"Lorem Ipsum ", "B":"Lorem Ipsum ", "C":"Lorem Ipsum ", "D":"Lorem Ipsum ", "E":"Lorem Ipsum ", "F":"Lorem Ipsum ", "G":301, "H":[ { …
Grégoire Borel
  • 1,880
  • 3
  • 33
  • 55
7
votes
3 answers

json string with multiple types to Map[String, Object]

I have this json string: { "startDate" : "2014-12-17T14:31:40Z", "name" : "Izek", "age" : 12 } When I convert it with Jackson to Map[String, Object] the type of startDate is String how I can tell Jackson to convert it to DateTime type?
igreenfield
  • 1,618
  • 19
  • 36
7
votes
3 answers

spring mvc restcontroller return json string

I have a Spring MVC controller with the following method: @RequestMapping(value = "/stringtest", method = RequestMethod.GET) public String simpletest() throws Exception { return "test"; } This sits inside a controller that starts like…
Jesse Pangburn
  • 655
  • 1
  • 7
  • 16
7
votes
3 answers

Map a Jsonpath output to a list of POJOs

I'm trying to map directly the output of a Jsonpath to a list of POJO. I'm using Jackson as a mapping provider. Jsonpath output: { "actions" : [ { "parameterDefinitions" : [ { "defaultParameterValue" : { …
tduchateau
  • 4,351
  • 2
  • 29
  • 40
7
votes
3 answers

Jackson2ObjectMapperBuilder enable field visibility ANY

I'm using spring-boot and want to customize the ObjectMapper created. What I want to do is be able to serialize objects that do not have a getter or setters. Before this could be done by putting JsonAutoDetect.Visibility.ANY on the…
Jonas Geiregat
  • 5,214
  • 4
  • 41
  • 60
7
votes
2 answers

Serializing Joda DateTime with Jackson and Spring

I am having problems consistently serializing and deserializing a Joda DateTime from java to json and back again using Spring Boot and Jackson-databind 2.5.2. My pom.xml looks like this.
crowmagnumb
  • 6,621
  • 9
  • 33
  • 42
7
votes
2 answers

Jackson custom serialization getter

Let's say I have a POJO like: public class User { private Long id; private String username; // usual getters and setters .... // only for serialisation purposes public String getUpperUsername() { return…
user3159152
  • 611
  • 4
  • 12
  • 20
7
votes
1 answer

Jackson JSON provider for cxf:rsServer

I'm implementing a REST service using Camel's cxfrs component. Various examples I've seen around the inets say I can get the service to return a JSON serialization of the object in question using a cxf:providers tag, like so
7
votes
2 answers

Spring MVC @Scope proxy bean & Jackson 2

I'm trying to develop a small Spring MVC application, where i'd like User object to initialize from the beginning of each session. I have the User class @Component @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS) public class…
silent-box
  • 1,649
  • 3
  • 21
  • 40
7
votes
5 answers

Android with Gradle (Java finished with non-zero exit value 2)

This is my .gradle file: apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "com.test.test" minSdkVersion 15 targetSdkVersion 21 …
Hammerin87
  • 65
  • 1
  • 1
  • 8