This Jackson extension handles reading and writing of data encoded in Smile
data format ("binary JSON").
It extends standard Jackson streaming API (JsonFactory
, JsonParser
, JsonGenerator
), and as such works seamlessly with all the higher level data abstractions (data binding, tree model, and pluggable extensions).
Module has been mature since Jackson 1.6, and is used widely (over 150 projects), often as a dynamically configurable alternative to textual JSON.
It also works very well for use cases like caching, especially when databinding is configured to serialize POJOs as Arrays which can further reduce size of serialized objects.
To use this module on Maven-based projects, use following dependency:
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-smile</artifactId>
<version>2.8.9</version>
</dependency>
(or whatever version is most up-to-date at the moment)
Basic usage is by using SmileFactory
in places where you would usually use JsonFactory
:
ObjectMapper mapper = new ObjectMapper(new SmileFactory());
// (or can construct factory, configure instance with 'SmileParser.Feature'
// and 'SmileGenerator.Feature' first
SomeType value = ...;
byte[] smileData = mapper.writeValueAsBytes(value);
SomeType otherValue = mapper.readValue(smileData, SomeType.class);
- Smile-format discussion group
- Non-java Smile codecs (for interoperability):