Class JsonCodec
java.lang.Object
com.github.cafapi.common.codecs.json.JsonCodec
Implementation of Codec that supports serialisation and deserialisation to and form JSON format.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Tdeserialise(byte[] data, Class<T> clazz, DecodeMethod method) Deserialise the given data into the specified class.<T> Tdeserialise(InputStream stream, Class<T> clazz, DecodeMethod method) Deserialise the given data into the specified class using the default decode method.protected com.fasterxml.jackson.databind.ObjectMappergetMapper(DecodeMethod method) byte[]Serialise the given object into a byte data form.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.cafapi.common.api.Codec
deserialise, deserialise
-
Constructor Details
-
JsonCodec
public JsonCodec()
-
-
Method Details
-
deserialise
Description copied from interface:CodecDeserialise the given data into the specified class.- Specified by:
deserialisein interfaceCodec- Type Parameters:
T- the class the serialised data represents- Parameters:
data- the serialised dataclazz- the class the serialised data representsmethod- specifies whether to use strict or lenient decoding during deserialisation- Returns:
- an instance of the class specified represented by the data
- Throws:
CodecException- if the data could not be deserialised
-
deserialise
public <T> T deserialise(InputStream stream, Class<T> clazz, DecodeMethod method) throws CodecException Description copied from interface:CodecDeserialise the given data into the specified class using the default decode method.- Specified by:
deserialisein interfaceCodec- Type Parameters:
T- the class the serialised data represents- Parameters:
stream- the serialised data as a streamclazz- the class the serialised data representsmethod- specifies whether to use strict or lenient decoding during deserialisation- Returns:
- an instance of the class specified represented by the data
- Throws:
CodecException- if the data could not be deserialised
-
serialise
Description copied from interface:CodecSerialise the given object into a byte data form.- Specified by:
serialisein interfaceCodec- Parameters:
object- the object to serialise- Returns:
- the serialised data of the given object
- Throws:
CodecException- if the object could not be serialised
-
getMapper
-