public class JsonReader extends Object implements Closeable
JsonReader.objectToJava(String json)
. This will
return a typed Java object graph.JsonReader.jsonToMaps(String json)
. This will
return an untyped object representation of the JSON String as a Map of Maps, where
the fields are the Map keys, and the field values are the associated Map's values. You can
call the JsonWriter.objectToJava() method with the returned Map, and it will serialize
the Graph into the identical JSON stream from which it was read.
JsonReader(InputStream in)
and then call
readObject()
. Cast the return value of readObject() to the Java class that was the root of
the graph.
JsonReader(InputStream in, true)
and then call
readObject()
. The return value will be a Map of Maps.
Modifier and Type | Class and Description |
---|---|
static class |
JsonReader.BigDecimalReader |
static class |
JsonReader.BigIntegerReader |
static class |
JsonReader.CalendarReader |
static interface |
JsonReader.ClassFactory |
static class |
JsonReader.ClassReader |
static class |
JsonReader.CollectionFactory
Use to create new instances of collection interfaces (needed for empty collections)
|
static class |
JsonReader.DateReader |
static interface |
JsonReader.JsonClassReader |
static class |
JsonReader.LocaleReader |
static class |
JsonReader.MapFactory
Use to create new instances of Map interfaces (needed for empty Maps)
|
static class |
JsonReader.SqlDateReader |
static class |
JsonReader.StringBufferReader |
static class |
JsonReader.StringBuilderReader |
static class |
JsonReader.StringReader |
static class |
JsonReader.TimestampReader |
static class |
JsonReader.TimeZoneReader |
Modifier and Type | Field and Description |
---|---|
static int |
MAX_CODE_POINT |
static char |
MIN_HIGH_SURROGATE |
static char |
MIN_LOW_SURROGATE |
static int |
MIN_SUPPLEMENTARY_CODE_POINT |
Constructor and Description |
---|
JsonReader() |
JsonReader(InputStream in) |
JsonReader(InputStream in,
boolean noObjects) |
Modifier and Type | Method and Description |
---|---|
static void |
addNotCustomReader(Class c) |
static void |
addReader(Class c,
JsonReader.JsonClassReader reader) |
static void |
assignInstantiator(Class c,
JsonReader.ClassFactory factory)
For difficult to instantiate classes, you can add your own ClassFactory
which will be called when the passed in class 'c' is encountered.
|
void |
close() |
static boolean |
isPrimitive(Class c) |
Object |
jsonObjectsToJava(JsonObject root)
Convert a root JsonObject that represents parsed JSON, into
an actual Java object.
|
static Object |
jsonToJava(String json)
Convert the passed in JSON string into a Java object graph.
|
static Map |
jsonToMaps(String json)
Convert the passed in JSON string into a Java object graph
that consists solely of Java Maps where the keys are the
fields and the values are primitives or other Maps (in the
case of objects).
|
protected Object |
readIfMatching(Object o,
Class compType,
LinkedList<JsonObject<String,Object>> stack) |
Object |
readObject()
Finite State Machine (FSM) used to parse the JSON input into
JsonObject's (Maps).
|
static Object |
toJava(String json)
Deprecated.
|
static Map |
toMaps(String json)
Deprecated.
|
public static final int MAX_CODE_POINT
public static final int MIN_SUPPLEMENTARY_CODE_POINT
public static final char MIN_LOW_SURROGATE
public static final char MIN_HIGH_SURROGATE
public JsonReader()
public JsonReader(InputStream in)
public JsonReader(InputStream in, boolean noObjects)
public static void assignInstantiator(Class c, JsonReader.ClassFactory factory)
public static void addReader(Class c, JsonReader.JsonClassReader reader)
public static void addNotCustomReader(Class c)
protected Object readIfMatching(Object o, Class compType, LinkedList<JsonObject<String,Object>> stack) throws IOException
IOException
@Deprecated public static Object toJava(String json)
json
- String JSON inputpublic static Object jsonToJava(String json) throws IOException
json
- String JSON inputIOException
- If an I/O error occurs@Deprecated public static Map toMaps(String json)
json
- String JSON inputpublic static Map jsonToMaps(String json) throws IOException
json
- String JSON inputIOException
- If an I/O error occurspublic Object readObject() throws IOException
IOException
- for stream errors or parsing errors.public Object jsonObjectsToJava(JsonObject root) throws IOException
root
- JsonObject instance that was the root object from the
JSON input that was parsed in an earlier call to JsonReader.IOException
public static boolean isPrimitive(Class c)
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2014. All rights reserved.