T
- type of POJO for which a JSON codec is providedpublic abstract class OfJsonCodec<T extends Structure> extends AbstractJsonCodec<T>
Structure
classes. All JSON representations of the
Structure
will have an injected top-level "version" node that
correspond to the version from Structure.getVersion()
.
Accordingly, the JsonCodec.decode(ObjectNode)
method implemented by
sub-classes of this class must ensure that the ObjectNode parameter
indeed contains a "version" node so that it can re-hydrate the
Structure
POJO successfully.
Modifier and Type | Field and Description |
---|---|
static String |
VERSION |
log, mapper, NO_DECODING_SUP, root, roots
Modifier | Constructor and Description |
---|---|
protected |
OfJsonCodec(String root,
String roots) |
Modifier and Type | Method and Description |
---|---|
T |
decode(String json)
Decodes the JSON string into a typed POJO.
|
List<T> |
decodeList(String json)
Decodes the JSON string into a typed list of POJO.
|
String |
encode(T pojo,
boolean prettyPrint)
Encodes the given POJO to its JSON string representation.
|
String |
encodeList(Collection<T> pojos,
boolean prettyPrint)
Encodes the collection of POJOs to their JSON string representation.
|
protected ProtocolVersion |
version(com.fasterxml.jackson.databind.node.ObjectNode node)
Retrieve the protocol version from a given json node that contains the
VERSION tag. |
arrayNode, encodeIterator, encodeIterator, encodeList, fromEnums, isMissingContent, longVal, objectNode, read, root, roots, toEnums, write
public static final String VERSION
public T decode(String json)
JsonCodec
public List<T> decodeList(String json)
JsonCodec
decodeList
in interface JsonCodec<T extends Structure>
decodeList
in class AbstractJsonCodec<T extends Structure>
json
- JSON string representation of the typed list of POJOspublic String encode(T pojo, boolean prettyPrint)
JsonCodec
public String encodeList(Collection<T> pojos, boolean prettyPrint)
JsonCodec
encodeList
in interface JsonCodec<T extends Structure>
encodeList
in class AbstractJsonCodec<T extends Structure>
pojos
- list of POJO's to encodeprettyPrint
- human-readable formatted JSON if true, single-line
JSON otherwiseprotected ProtocolVersion version(com.fasterxml.jackson.databind.node.ObjectNode node)
VERSION
tag.node
- JSON node that contains the VERSION tagCopyright © 2015. All Rights Reserved.