Package io.protostuff
Class JsonIOUtil
- java.lang.Object
-
- io.protostuff.JsonIOUtil
-
public final class JsonIOUtil extends java.lang.ObjectUtility for the JSON serialization/deserialization of messages and objects tied to a schema.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJsonIOUtil.FactoryA custom factory simply to expose certain fields.
-
Field Summary
Fields Modifier and Type Field Description static JsonIOUtil.FactoryDEFAULT_JSON_FACTORYThe default json factory for creating json parsers and generators.
-
Constructor Summary
Constructors Modifier Constructor Description privateJsonIOUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> voidmergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean numeric)Merges themessagewith the byte array using the givenschema.static <T> voidmergeFrom(byte[] data, T message, Schema<T> schema, boolean numeric)Merges themessagewith the byte array using the givenschema.static <T> voidmergeFrom(com.fasterxml.jackson.core.JsonParser parser, T message, Schema<T> schema, boolean numeric)Merges themessagefrom the JsonParser using the givenschema.static <T> voidmergeFrom(java.io.InputStream in, T message, Schema<T> schema, boolean numeric)Merges themessagefrom theInputStreamusing the givenschema.static <T> voidmergeFrom(java.io.InputStream in, T message, Schema<T> schema, boolean numeric, LinkedBuffer buffer)Merges themessagefrom theInputStreamusing the givenschema.static <T> voidmergeFrom(java.io.Reader reader, T message, Schema<T> schema, boolean numeric)Merges themessagefrom theReaderusing the givenschema.static com.fasterxml.jackson.core.json.UTF8JsonGeneratornewJsonGenerator(java.io.OutputStream out, byte[] buf)Creates aUTF8JsonGeneratorfor the outputstream with the supplied bufoutBufferto use.(package private) static com.fasterxml.jackson.core.json.UTF8JsonGeneratornewJsonGenerator(java.io.OutputStream out, byte[] buf, int offset, boolean bufferRecyclable, com.fasterxml.jackson.core.io.IOContext context)Creates aUTF8JsonGeneratorfor the outputstream with the supplied bufoutBufferto use.static com.fasterxml.jackson.core.json.UTF8StreamJsonParsernewJsonParser(java.io.InputStream in, byte[] buf, int offset, int limit)Creates aUTF8StreamJsonParserfrom the inputstream with the supplied bufinBufferto use.(package private) static com.fasterxml.jackson.core.json.UTF8StreamJsonParsernewJsonParser(java.io.InputStream in, byte[] buf, int offset, int limit, boolean bufferRecyclable, com.fasterxml.jackson.core.io.IOContext context)Creates aUTF8StreamJsonParserfrom the inputstream with the supplied bufinBufferto use.static PipenewPipe(byte[] data, boolean numeric)Creates a json pipe from a byte array.static PipenewPipe(byte[] data, int offset, int length, boolean numeric)Creates a json pipe from a byte array.static PipenewPipe(com.fasterxml.jackson.core.JsonParser parser, boolean numeric)Creates a json pipe from aJsonParser.static PipenewPipe(java.io.InputStream in, boolean numeric)Creates a json pipe from anInputStream.static PipenewPipe(java.io.Reader reader, boolean numeric)Creates a json pipe from aReader.static <T> java.util.List<T>parseListFrom(com.fasterxml.jackson.core.JsonParser parser, Schema<T> schema, boolean numeric)Parses themessagesfrom the parser using the givenschema.static <T> java.util.List<T>parseListFrom(java.io.InputStream in, Schema<T> schema, boolean numeric)Parses themessagesfrom the stream using the givenschema.static <T> java.util.List<T>parseListFrom(java.io.InputStream in, Schema<T> schema, boolean numeric, LinkedBuffer buffer)Parses themessagesfrom the stream using the givenschema.static <T> java.util.List<T>parseListFrom(java.io.Reader reader, Schema<T> schema, boolean numeric)Parses themessagesfrom the reader using the givenschema.static <T> byte[]toByteArray(T message, Schema<T> schema, boolean numeric)Serializes themessageinto a byte array using the givenschema.static <T> byte[]toByteArray(T message, Schema<T> schema, boolean numeric, LinkedBuffer buffer)Serializes themessageinto a byte array using the givenschema.static <T> voidwriteListTo(com.fasterxml.jackson.core.JsonGenerator generator, java.util.List<T> messages, Schema<T> schema, boolean numeric)Serializes themessagesinto the generator using the given schema.static <T> voidwriteListTo(java.io.OutputStream out, java.util.List<T> messages, Schema<T> schema, boolean numeric)Serializes themessagesinto the stream using the given schema.static <T> voidwriteListTo(java.io.OutputStream out, java.util.List<T> messages, Schema<T> schema, boolean numeric, LinkedBuffer buffer)Serializes themessagesinto the stream using the given schema.static <T> voidwriteListTo(java.io.Writer writer, java.util.List<T> messages, Schema<T> schema, boolean numeric)Serializes themessagesinto the writer using the given schema.static <T> voidwriteTo(com.fasterxml.jackson.core.JsonGenerator generator, T message, Schema<T> schema, boolean numeric)Serializes themessageinto a JsonGenerator using the givenschema.static <T> voidwriteTo(java.io.OutputStream out, T message, Schema<T> schema, boolean numeric)Serializes themessageinto anOutputStreamusing the givenschema.static <T> voidwriteTo(java.io.OutputStream out, T message, Schema<T> schema, boolean numeric, LinkedBuffer buffer)Serializes themessageinto anOutputStreamusing the givenschema.static <T> voidwriteTo(java.io.Writer writer, T message, Schema<T> schema, boolean numeric)Serializes themessageinto aWriterusing the givenschema.
-
-
-
Field Detail
-
DEFAULT_JSON_FACTORY
public static final JsonIOUtil.Factory DEFAULT_JSON_FACTORY
The default json factory for creating json parsers and generators.
-
-
Method Detail
-
newPipe
public static Pipe newPipe(byte[] data, boolean numeric) throws java.io.IOException
Creates a json pipe from a byte array.- Throws:
java.io.IOException
-
newPipe
public static Pipe newPipe(byte[] data, int offset, int length, boolean numeric) throws java.io.IOException
Creates a json pipe from a byte array.- Throws:
java.io.IOException
-
newPipe
public static Pipe newPipe(java.io.InputStream in, boolean numeric) throws java.io.IOException
Creates a json pipe from anInputStream.- Throws:
java.io.IOException
-
newPipe
public static Pipe newPipe(java.io.Reader reader, boolean numeric) throws java.io.IOException
Creates a json pipe from aReader.- Throws:
java.io.IOException
-
newPipe
public static Pipe newPipe(com.fasterxml.jackson.core.JsonParser parser, boolean numeric) throws java.io.IOException
Creates a json pipe from aJsonParser.- Throws:
java.io.IOException
-
newJsonParser
public static com.fasterxml.jackson.core.json.UTF8StreamJsonParser newJsonParser(java.io.InputStream in, byte[] buf, int offset, int limit) throws java.io.IOExceptionCreates aUTF8StreamJsonParserfrom the inputstream with the supplied bufinBufferto use.- Throws:
java.io.IOException
-
newJsonParser
static com.fasterxml.jackson.core.json.UTF8StreamJsonParser newJsonParser(java.io.InputStream in, byte[] buf, int offset, int limit, boolean bufferRecyclable, com.fasterxml.jackson.core.io.IOContext context) throws java.io.IOExceptionCreates aUTF8StreamJsonParserfrom the inputstream with the supplied bufinBufferto use.- Throws:
java.io.IOException
-
newJsonGenerator
public static com.fasterxml.jackson.core.json.UTF8JsonGenerator newJsonGenerator(java.io.OutputStream out, byte[] buf)Creates aUTF8JsonGeneratorfor the outputstream with the supplied bufoutBufferto use.
-
newJsonGenerator
static com.fasterxml.jackson.core.json.UTF8JsonGenerator newJsonGenerator(java.io.OutputStream out, byte[] buf, int offset, boolean bufferRecyclable, com.fasterxml.jackson.core.io.IOContext context)Creates aUTF8JsonGeneratorfor the outputstream with the supplied bufoutBufferto use.
-
mergeFrom
public static <T> void mergeFrom(byte[] data, T message, Schema<T> schema, boolean numeric) throws java.io.IOExceptionMerges themessagewith the byte array using the givenschema.- Throws:
java.io.IOException
-
mergeFrom
public static <T> void mergeFrom(byte[] data, int offset, int length, T message, Schema<T> schema, boolean numeric) throws java.io.IOExceptionMerges themessagewith the byte array using the givenschema.- Throws:
java.io.IOException
-
mergeFrom
public static <T> void mergeFrom(java.io.InputStream in, T message, Schema<T> schema, boolean numeric) throws java.io.IOExceptionMerges themessagefrom theInputStreamusing the givenschema.- Throws:
java.io.IOException
-
mergeFrom
public static <T> void mergeFrom(java.io.InputStream in, T message, Schema<T> schema, boolean numeric, LinkedBuffer buffer) throws java.io.IOExceptionMerges themessagefrom theInputStreamusing the givenschema.The
LinkedBuffer's internal byte array will be used when reading the message.- Throws:
java.io.IOException
-
mergeFrom
public static <T> void mergeFrom(java.io.Reader reader, T message, Schema<T> schema, boolean numeric) throws java.io.IOExceptionMerges themessagefrom theReaderusing the givenschema.- Throws:
java.io.IOException
-
mergeFrom
public static <T> void mergeFrom(com.fasterxml.jackson.core.JsonParser parser, T message, Schema<T> schema, boolean numeric) throws java.io.IOExceptionMerges themessagefrom the JsonParser using the givenschema.- Throws:
java.io.IOException
-
toByteArray
public static <T> byte[] toByteArray(T message, Schema<T> schema, boolean numeric)Serializes themessageinto a byte array using the givenschema.
-
toByteArray
public static <T> byte[] toByteArray(T message, Schema<T> schema, boolean numeric, LinkedBuffer buffer)Serializes themessageinto a byte array using the givenschema.The
LinkedBuffer's internal byte array will be used as the primary buffer when writing the message.
-
writeTo
public static <T> void writeTo(java.io.OutputStream out, T message, Schema<T> schema, boolean numeric) throws java.io.IOExceptionSerializes themessageinto anOutputStreamusing the givenschema.- Throws:
java.io.IOException
-
writeTo
public static <T> void writeTo(java.io.OutputStream out, T message, Schema<T> schema, boolean numeric, LinkedBuffer buffer) throws java.io.IOExceptionSerializes themessageinto anOutputStreamusing the givenschema.The
LinkedBuffer's internal byte array will be used as the primary buffer when writing the message.- Throws:
java.io.IOException
-
writeTo
public static <T> void writeTo(java.io.Writer writer, T message, Schema<T> schema, boolean numeric) throws java.io.IOExceptionSerializes themessageinto aWriterusing the givenschema.- Throws:
java.io.IOException
-
writeTo
public static <T> void writeTo(com.fasterxml.jackson.core.JsonGenerator generator, T message, Schema<T> schema, boolean numeric) throws java.io.IOExceptionSerializes themessageinto a JsonGenerator using the givenschema.- Throws:
java.io.IOException
-
writeListTo
public static <T> void writeListTo(java.io.OutputStream out, java.util.List<T> messages, Schema<T> schema, boolean numeric) throws java.io.IOExceptionSerializes themessagesinto the stream using the given schema.- Throws:
java.io.IOException
-
writeListTo
public static <T> void writeListTo(java.io.OutputStream out, java.util.List<T> messages, Schema<T> schema, boolean numeric, LinkedBuffer buffer) throws java.io.IOExceptionSerializes themessagesinto the stream using the given schema.The
LinkedBuffer's internal byte array will be used as the primary buffer when writing the message.- Throws:
java.io.IOException
-
writeListTo
public static <T> void writeListTo(java.io.Writer writer, java.util.List<T> messages, Schema<T> schema, boolean numeric) throws java.io.IOExceptionSerializes themessagesinto the writer using the given schema.- Throws:
java.io.IOException
-
writeListTo
public static <T> void writeListTo(com.fasterxml.jackson.core.JsonGenerator generator, java.util.List<T> messages, Schema<T> schema, boolean numeric) throws java.io.IOExceptionSerializes themessagesinto the generator using the given schema.- Throws:
java.io.IOException
-
parseListFrom
public static <T> java.util.List<T> parseListFrom(java.io.InputStream in, Schema<T> schema, boolean numeric) throws java.io.IOExceptionParses themessagesfrom the stream using the givenschema.- Throws:
java.io.IOException
-
parseListFrom
public static <T> java.util.List<T> parseListFrom(java.io.InputStream in, Schema<T> schema, boolean numeric, LinkedBuffer buffer) throws java.io.IOExceptionParses themessagesfrom the stream using the givenschema.The
LinkedBuffer's internal byte array will be used when reading the message.- Throws:
java.io.IOException
-
parseListFrom
public static <T> java.util.List<T> parseListFrom(java.io.Reader reader, Schema<T> schema, boolean numeric) throws java.io.IOExceptionParses themessagesfrom the reader using the givenschema.- Throws:
java.io.IOException
-
parseListFrom
public static <T> java.util.List<T> parseListFrom(com.fasterxml.jackson.core.JsonParser parser, Schema<T> schema, boolean numeric) throws java.io.IOExceptionParses themessagesfrom the parser using the givenschema.- Throws:
java.io.IOException
-
-