Jackson - Overview



Advertisements


Jackson is a simple java based library to serialize java objects to JSON and vice versa.

Features

  • Easy to use. - jackson API provides a high level facade to simplify commonly used use cases.

  • No need to create mapping. - jackson API provides default mapping for most of the objects to be serialized.

  • Performance. - jackson is quiet fast and is of low memory footprint and is suitable for large object graphs or systems.

  • Clean JSON. - jackson creates a clean and compact JSON results which is easy to read.

  • No Dependency. - jackson library does not require any other library apart from jdk.

  • Open Source - jackson library is open source and is free to use.

Three ways of processing JSON

Jackson provides three alternative ways to process JSON

  • Streaming API - reads and writes JSON content as discrete events. JsonParser reads the data whereas JsonGenerator writes the data. It is most powerful approach among the three and is of lowest overhead and fastest in read/write opreations. It is Analogus to Stax parser for XML.

  • Tree Model - prepares a in-memory tree representation of the JSON document. ObjectMapper build tree of JsonNode nodes. It is most flexible approach. It is analogus to DOM parser for XML.

  • Data Binding - converts JSON to and from POJO (Plain Old Java Object) using property accessor or using annotations. It is of two type.

    • Simple Data Binding - Converts JSON to and from Java Maps, Lists, Strings, Numbers, Booleans and null objects.

    • Full Data Binding - Converts JSON to and from any JAVA type.

    ObjectMapper reads/writes JSON for both types of data bindings. Data Binding is most convenient way and is analogus to JAXB parer for XML.



Advertisements