Jackson: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 62: Line 62:
{{Internal|Jackson Full Data Binding|Full Data Binding}}
{{Internal|Jackson Full Data Binding|Full Data Binding}}


=<span id='Thread_Safety'></span><span id=''></span><span id='Configuration'></span><span id='Specifying_a_Date_Format'></span>ObjectMapper=
=Concepts=
 
==<span id='Thread_Safety'></span><span id=''></span><span id='Configuration'></span><span id='Specifying_a_Date_Format'></span>ObjectMapper==


{{Internal|Jackson ObjectMapper|ObjectMapper}}
{{Internal|Jackson ObjectMapper|ObjectMapper}}


==JsonGenerator==
<font color=darkgray>TODO</font>
==View==
<font color=darkgray>TODO</font>
=Annotations=
=Annotations=



Revision as of 21:54, 14 November 2018

External

Internal

Overview

Jackson is a Java library for processing JSON data format. It has support for marshaling and unmarshalling Java to and from JSON. It has a JAX-RS content handler that can automatically convert between Java objects and JSON, and vice-versa. It can generate JSON schemas from a Java object model.

Dependencies

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.8.7</version>
</dependency>

If the tree model is used, this is also required:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.8.7</version>
</dependency>

JSON Processing Methods

Jackson offers three alternative methods for processing JSON:

Streaming API

The Streaming API reads and writes JSON as a series of discrete events, in a mode called "incremental parsing/generation". The other methods (Tree Model and Simple Data Binding and Full Data Binding) are built in top of it. However, this is not the most convenient method, because is relatively low level. For more details, see:

Streaming API

Tree Model

A JSON document is converted into a mutable in-memory tree representation of the JSON document. Tree model is arguably the most flexible of all three methods. For more details, see:

Tree Model

Simple Data Binding

Jackson extracts data from JSON and initializes an in-memory Java Map/List/String/Number/Boolean/null hierarchy. Jackson specialized data representation types such as JsonNode are not used.

Simple Data Binding

Full Data Binding

Jackson converts JSON to any Java bean type, and any Java bean type can be automatically written as JSON. Data binding is arguably the most convenient of all three methods.

Full Data Binding

Concepts

ObjectMapper

ObjectMapper

JsonGenerator

TODO

View

TODO

Annotations