public abstract class JsonReader<T>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
JsonReader.FieldMapping
If you're implementing a
JsonReader for a JSON object, you can use this to map
field names to a number you can switch on to efficiently locate assign a
field. |
static class |
JsonReader.FileLoadException |
Modifier and Type | Field and Description |
---|---|
static JsonReader<byte[]> |
BinaryReader |
static JsonReader<java.lang.Boolean> |
BooleanReader |
static JsonReader<java.lang.Float> |
Float32Reader |
static JsonReader<java.lang.Double> |
Float64Reader |
static JsonReader<java.lang.Integer> |
Int32Reader |
static JsonReader<java.lang.Long> |
Int64Reader |
static JsonReader<java.lang.String> |
StringReader |
static JsonReader<java.lang.Long> |
UInt32Reader |
static JsonReader<java.lang.Long> |
UInt64Reader |
static JsonReader<java.lang.Long> |
UnsignedLongReader |
static JsonReader<java.lang.Object> |
VoidReader |
Constructor and Description |
---|
JsonReader() |
Modifier and Type | Method and Description |
---|---|
static com.fasterxml.jackson.core.JsonLocation |
expectArrayEnd(com.fasterxml.jackson.core.JsonParser parser) |
static com.fasterxml.jackson.core.JsonLocation |
expectArrayStart(com.fasterxml.jackson.core.JsonParser parser) |
static void |
expectObjectEnd(com.fasterxml.jackson.core.JsonParser parser) |
static com.fasterxml.jackson.core.JsonLocation |
expectObjectStart(com.fasterxml.jackson.core.JsonParser parser) |
static boolean |
isArrayEnd(com.fasterxml.jackson.core.JsonParser parser) |
static boolean |
isArrayStart(com.fasterxml.jackson.core.JsonParser parser) |
static com.fasterxml.jackson.core.JsonToken |
nextToken(com.fasterxml.jackson.core.JsonParser parser)
A wrapper around 'JsonParser.nextToken' that throws our own better
JsonReadException
instead of Jackson's JsonParseException . |
abstract T |
read(com.fasterxml.jackson.core.JsonParser parser) |
static boolean |
readBoolean(com.fasterxml.jackson.core.JsonParser parser) |
static double |
readDouble(com.fasterxml.jackson.core.JsonParser parser) |
static <T> T |
readEnum(com.fasterxml.jackson.core.JsonParser parser,
java.util.HashMap<java.lang.String,T> values,
T catch_all) |
T |
readField(com.fasterxml.jackson.core.JsonParser parser,
java.lang.String fieldName,
T v) |
T |
readFields(com.fasterxml.jackson.core.JsonParser parser) |
T |
readFromFile(java.io.File file) |
T |
readFromFile(java.lang.String filePath) |
T |
readFromTags(java.lang.String[] tags,
com.fasterxml.jackson.core.JsonParser parser) |
T |
readFully(byte[] utf8Body) |
T |
readFully(java.io.InputStream utf8Body) |
T |
readFully(com.fasterxml.jackson.core.JsonParser parser) |
T |
readFully(java.lang.String body) |
T |
readOptional(com.fasterxml.jackson.core.JsonParser parser) |
static java.lang.String[] |
readTags(com.fasterxml.jackson.core.JsonParser parser)
Helper to read and parse the optional ".tag" field.
|
static long |
readUnsignedLong(com.fasterxml.jackson.core.JsonParser parser) |
static long |
readUnsignedLongField(com.fasterxml.jackson.core.JsonParser parser,
java.lang.String fieldName,
long v) |
static void |
skipValue(com.fasterxml.jackson.core.JsonParser parser) |
void |
validate(T value) |
public static final JsonReader<java.lang.Long> UnsignedLongReader
public static final JsonReader<java.lang.Long> Int64Reader
public static final JsonReader<java.lang.Integer> Int32Reader
public static final JsonReader<java.lang.Long> UInt64Reader
public static final JsonReader<java.lang.Long> UInt32Reader
public static final JsonReader<java.lang.Double> Float64Reader
public static final JsonReader<java.lang.Float> Float32Reader
public static final JsonReader<java.lang.String> StringReader
public static final JsonReader<byte[]> BinaryReader
public static final JsonReader<java.lang.Boolean> BooleanReader
public static final JsonReader<java.lang.Object> VoidReader
public abstract T read(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public T readFromTags(java.lang.String[] tags, com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public T readFields(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public void validate(T value)
public final T readField(com.fasterxml.jackson.core.JsonParser parser, java.lang.String fieldName, T v) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public final T readOptional(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static java.lang.String[] readTags(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static com.fasterxml.jackson.core.JsonToken nextToken(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
JsonReadException
instead of Jackson's JsonParseException
.
JsonParseException is bad for two reasons. First, it extends IOException, which makes it easy to
miss. Second, there's no way to get the original error message, which makes it hard to chain
logical location information (see JsonReadException.addFieldContext(java.lang.String)
and
JsonReadException.addArrayContext(int)
).
java.io.IOException
JsonReadException
public static com.fasterxml.jackson.core.JsonLocation expectObjectStart(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static void expectObjectEnd(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static com.fasterxml.jackson.core.JsonLocation expectArrayStart(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static com.fasterxml.jackson.core.JsonLocation expectArrayEnd(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static boolean isArrayEnd(com.fasterxml.jackson.core.JsonParser parser)
public static boolean isArrayStart(com.fasterxml.jackson.core.JsonParser parser)
public static void skipValue(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static long readUnsignedLong(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static long readUnsignedLongField(com.fasterxml.jackson.core.JsonParser parser, java.lang.String fieldName, long v) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static boolean readBoolean(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static double readDouble(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public static <T> T readEnum(com.fasterxml.jackson.core.JsonParser parser, java.util.HashMap<java.lang.String,T> values, T catch_all) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public T readFully(java.io.InputStream utf8Body) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException
public T readFully(java.lang.String body) throws JsonReadException
JsonReadException
public T readFully(byte[] utf8Body) throws JsonReadException
JsonReadException
public T readFromFile(java.lang.String filePath) throws JsonReader.FileLoadException
JsonReader.FileLoadException
public T readFromFile(java.io.File file) throws JsonReader.FileLoadException
JsonReader.FileLoadException
public T readFully(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException, JsonReadException
java.io.IOException
JsonReadException