public abstract class JsonReader<T> extends 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<Boolean> |
BooleanReader |
static JsonReader<Float> |
Float32Reader |
static JsonReader<Double> |
Float64Reader |
static JsonReader<Integer> |
Int32Reader |
static JsonReader<Long> |
Int64Reader |
static JsonReader<String> |
StringReader |
static JsonReader<Long> |
UInt32Reader |
static JsonReader<Long> |
UInt64Reader |
static JsonReader<Long> |
UnsignedLongReader |
static JsonReader<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,
HashMap<String,T> values,
T catch_all) |
T |
readField(com.fasterxml.jackson.core.JsonParser parser,
String fieldName,
T v) |
T |
readFields(com.fasterxml.jackson.core.JsonParser parser) |
T |
readFromFile(File file) |
T |
readFromFile(String filePath) |
T |
readFromTags(String[] tags,
com.fasterxml.jackson.core.JsonParser parser) |
T |
readFully(byte[] utf8Body) |
T |
readFully(InputStream utf8Body) |
T |
readFully(com.fasterxml.jackson.core.JsonParser parser) |
T |
readFully(String body) |
T |
readOptional(com.fasterxml.jackson.core.JsonParser parser) |
static 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,
String fieldName,
long v) |
static void |
skipValue(com.fasterxml.jackson.core.JsonParser parser) |
void |
validate(T value) |
public static final JsonReader<Long> UnsignedLongReader
public static final JsonReader<Long> Int64Reader
public static final JsonReader<Integer> Int32Reader
public static final JsonReader<Long> UInt64Reader
public static final JsonReader<Long> UInt32Reader
public static final JsonReader<Double> Float64Reader
public static final JsonReader<Float> Float32Reader
public static final JsonReader<String> StringReader
public static final JsonReader<byte[]> BinaryReader
public static final JsonReader<Boolean> BooleanReader
public static final JsonReader<Object> VoidReader
public abstract T read(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public T readFromTags(String[] tags, com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public T readFields(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public void validate(T value)
public final T readField(com.fasterxml.jackson.core.JsonParser parser, String fieldName, T v) throws IOException, JsonReadException
IOException
JsonReadException
public final T readOptional(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public static String[] readTags(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public static com.fasterxml.jackson.core.JsonToken nextToken(com.fasterxml.jackson.core.JsonParser parser) throws 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)
).
IOException
JsonReadException
public static com.fasterxml.jackson.core.JsonLocation expectObjectStart(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public static void expectObjectEnd(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public static com.fasterxml.jackson.core.JsonLocation expectArrayStart(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public static com.fasterxml.jackson.core.JsonLocation expectArrayEnd(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
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 IOException, JsonReadException
IOException
JsonReadException
public static long readUnsignedLong(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public static long readUnsignedLongField(com.fasterxml.jackson.core.JsonParser parser, String fieldName, long v) throws IOException, JsonReadException
IOException
JsonReadException
public static boolean readBoolean(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public static double readDouble(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
public static <T> T readEnum(com.fasterxml.jackson.core.JsonParser parser, HashMap<String,T> values, T catch_all) throws IOException, JsonReadException
IOException
JsonReadException
public T readFully(InputStream utf8Body) throws IOException, JsonReadException
IOException
JsonReadException
public T readFully(String body) throws JsonReadException
JsonReadException
public T readFully(byte[] utf8Body) throws JsonReadException
JsonReadException
public T readFromFile(String filePath) throws JsonReader.FileLoadException
JsonReader.FileLoadException
public T readFromFile(File file) throws JsonReader.FileLoadException
JsonReader.FileLoadException
public T readFully(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException