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
8
votes
0 answers

How to ignore @JsonTypeInfo annotation during deserialization

Here is my Class with JSON Annotation @JsonIgnoreProperties(ignoreUnknown = true) @XmlRootElement @Entity @JsonTypeInfo(use=org.codehaus.jackson.annotate.JsonTypeInfo.Id.CLASS, include=As.PROPERTY, property="class") public class TestProfile…
yeshas
  • 81
  • 5
8
votes
4 answers

How to serialize lazy loaded entities with jackson module hibernate?

I`m trying to build an application with angularjs and springmvc.I have two classes Province and Comunidad. : @Entity(name="Provincia") @Table(name="T_PROVINCIA") public class Provincia implements Serializable{ private String idProvincia; private…
user2431903
  • 81
  • 1
  • 1
  • 3
8
votes
2 answers

Converting only the first level of object tree using Jackson ObjectMapper

Is it possible to make ObjectMapper convert only the actual object without converting the rest of the object tree recursively ? So that : Map props = new ObjectMapper().convertValue(obj, Map.class); results in a map of [field,…
lisak
  • 21,611
  • 40
  • 152
  • 243
8
votes
1 answer

org.codehaus.jackson.JsonParseException: Unexpected character ('' (code 65279 / 0xfeff)): expected a valid value

I'm facing an Strange problem, I'm very new to Android and Json. I'm consuming a RESTful WCF that shows a json response like this one: {"StatusCode":200,"Message":"","Result":{"Agencies":[],"Areas":[{"id":11,"area_name":"area…
Hector Sanchez
  • 2,297
  • 4
  • 26
  • 39
8
votes
2 answers

How to write boolean value as String in a json array?

JsonGenerator generator = new JsonFactory().createJsonGenerator(new JSONWriter(response)); generator.configure(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS, true); I used JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS to write…
Vignesh
  • 343
  • 2
  • 5
  • 13
8
votes
1 answer

Reading multiple JSON Objects from a single file into Java with Jackson

So I've done my best to research similar issues like this, but I'm fairly new to Java and JSON, so I apologize if this is redundant. I'm working on a simple text based RPG for my Java class this semester, and I want to store character information…
purpleSun
  • 95
  • 1
  • 1
  • 7
8
votes
2 answers

How to wrap a List as top level element in JSON generated by Jackson

I am running into a problem where I am trying to include a List as the root node, but I can't seem to be able to get this. Let me explain. Let's say we have a class "TestClass" class TestClass{ String propertyA; } Now, in some utility…
Seagull
  • 2,219
  • 6
  • 25
  • 33
8
votes
3 answers

Consuming a multipart/form-data via RESTful CXF

I've been working in a webservice that consumes and produces JSON files using Apache CXF in conjuction with Jackson. However, one of the service's methods should be able to save an uploaded image from a mobile application that makes a…
fcm
  • 6,305
  • 5
  • 24
  • 37
8
votes
1 answer

jackson serialize referenced object fields to root

I am working on POC of jersey REST service to be consumed by js MVC framework. On one of the forms i need to return UserProfile object (serialized to JSON by Jackson) which will be used to pre-populate HTML form. On form submission only a subset of…
user62058
  • 1,417
  • 2
  • 13
  • 22
8
votes
3 answers

Jackson JSON generator creates null JSON values for missing objects

I've started using Jackson as a JSON generator, as an alternative to google GSON. I've run into an issue where Jackson is generating object: null if the object is indeed null. GSON on the other hand generates NO entry in JSON, which is the…
geekyaleks
  • 1,281
  • 3
  • 18
  • 29
8
votes
2 answers

Jackson polymorphic type handling - property discarded

I have this JSON model class, public class Response { @JsonTypeInfo(use= JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="category") @JsonSubTypes({ @Type(value = Series.class, name = "Series"), …
zihaoyu
  • 5,483
  • 11
  • 42
  • 46
8
votes
3 answers

Decode Base64 with Jackson (or Spring)

This is the first time that I try to handle binary data so I'm quite new to this. I'm writing a REST service for uploading stuff, and I'm going to receive a Base64 encoded String. I've found this (standard Java), and I've also found an internal…
Enrichman
  • 11,157
  • 11
  • 67
  • 101
8
votes
2 answers

Jackson deserializing with custom deserializer causes a lot of GC calls and takes a lot longer

To solve my type mismatch problem discussed in this thread I created custom Deserializers and added them to ObjectMapper. However the performance deteriorates significantly with this. With default deserializer i get 1-2 Garbage collection calls in…
vKashyap
  • 580
  • 6
  • 17
8
votes
2 answers

Spring @ResponseBody produces an invalid JSON for primitive types

I have a code from a REST API which uses @ResponseBody to return the result, and a MappingJacksonHttpMessageConverter to return it in a JSON format. It all works well for complex objects. For primitives like int, boolean and string I get a JSON…
Oxmane
  • 117
  • 1
  • 2
  • 7
8
votes
2 answers

Serialize one class in two different ways with Jackson

In one of our projects we use a java webapp talking to a MongoDB instance. In the database, we use DBRefs to keep track of some object relations. We (de)serialize with POJO objects using jackson (using mongodb-jackson-mapper). However, we use the…
Gijs
  • 5,201
  • 1
  • 27
  • 42