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<Boolean> |
BooleanReader |
static JsonReader<String> |
StringReader |
Constructor and Description |
---|
JsonReader() |
Modifier and Type | Method and Description |
---|---|
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 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) |
T |
readField(com.fasterxml.jackson.core.JsonParser parser,
String fieldName,
T v) |
T |
readFromFile(File file) |
T |
readFromFile(String filePath) |
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 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) |
public static final JsonReader<String> StringReader
public static final JsonReader<Boolean> BooleanReader
public abstract T read(com.fasterxml.jackson.core.JsonParser parser) throws IOException, JsonReadException
IOException
JsonReadException
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 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 boolean isArrayEnd(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 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
Copyright © 2014. All rights reserved.