-
Notifications
You must be signed in to change notification settings - Fork 36
Custom Handlers
While the main configuration mechanism are the [Standard Features](JSON Features)), there are certain things you can customize by providing custom handers.
All these features are registered by using fluent with(...)
method of JSON
: result is a new JSON
instance, configured to use specified handler. Calls are often chained, and resulting JSON
may be cached, reused; or just discarded, as instances are light-weight and there is no overhead being cost of the Object construction itself.
It is possible to configure a standard Jackson streaming PrettyPrinter
to use, instead of the default one:
JSON j = JSON.std.with(new CustomPrettyPrinter());
MapBuilder
is a helper object used for construction java.util.Map
instances when binding JSON as Maps. One reason would be to use a specialized map like TreeMap
, instead of LinkedHashMap
; or to provide a more efficient read-only variant for small instances.
JSON j = JSON.std.with(new CustomMapBuilder());
Similar to MapBuilder
, it is possible to change kind of java.util.Collection
constructed:
JSON j = JSON.std.with(new CustomCollectionBuilder());
It is possible to register TreeCodec
, which would let a Tree Models (like Jackson JsonNode
) be recognized and handled automatically by Jackson jr:
JSON j = JSON.std.with(myTreeCodec);
To change the underlying Streaming API implementation -- for example, to support non-JSON output, like Smile