|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.api.client.json.JsonFactory
public abstract class JsonFactory
Abstract low-level JSON factory.
Implementation is thread-safe, and sub-classes must be thread-safe. For maximum efficiency, applications should use a single globally-shared instance of the JSON factory.
Constructor Summary | |
---|---|
JsonFactory()
|
Method Summary | ||
---|---|---|
abstract JsonGenerator |
createJsonGenerator(OutputStream out,
JsonEncoding enc)
Returns a new instance of a low-level JSON serializer for the given output stream and encoding. |
|
abstract JsonGenerator |
createJsonGenerator(Writer writer)
Returns a new instance of a low-level JSON serializer for the given writer. |
|
abstract JsonParser |
createJsonParser(InputStream in)
Returns a new instance of a low-level JSON parser for the given input stream. |
|
abstract JsonParser |
createJsonParser(Reader reader)
Returns a new instance of a low-level JSON parser for the given reader. |
|
abstract JsonParser |
createJsonParser(String value)
Returns a new instance of a low-level JSON parser for the given string value. |
|
|
fromInputStream(InputStream inputStream,
Class<T> destinationClass)
Parse and close an input stream as a JSON object, array, or value into a new instance of the given destination class using JsonParser.parseAndClose(Class, CustomizeJsonParser) . |
|
|
fromReader(Reader reader,
Class<T> destinationClass)
Parse and close a reader as a JSON object, array, or value into a new instance of the given destination class using JsonParser.parseAndClose(Class, CustomizeJsonParser) . |
|
|
fromString(String value,
Class<T> destinationClass)
Parses a string value as a JSON object, array, or value into a new instance of the given destination class using JsonParser.parse(Class, CustomizeJsonParser) . |
|
byte[] |
toByteArray(Object item)
Returns a UTF-8 encoded byte array of the serialized JSON representation for the given item using JsonGenerator.serialize(Object) . |
|
String |
toPrettyString(Object item)
Returns a pretty-printed serialized JSON string representation for the given item using JsonGenerator.serialize(Object) with JsonGenerator.enablePrettyPrint() . |
|
String |
toString(Object item)
Returns a serialized JSON string representation for the given item using JsonGenerator.serialize(Object) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JsonFactory()
Method Detail |
---|
public abstract JsonParser createJsonParser(InputStream in) throws IOException
in
- input stream
IOException
- if failedpublic abstract JsonParser createJsonParser(String value) throws IOException
value
- string value
IOException
- if failedpublic abstract JsonParser createJsonParser(Reader reader) throws IOException
reader
- reader
IOException
- if failedpublic abstract JsonGenerator createJsonGenerator(OutputStream out, JsonEncoding enc) throws IOException
out
- output streamenc
- encoding
IOException
- if failedpublic abstract JsonGenerator createJsonGenerator(Writer writer) throws IOException
writer
- writer
IOException
- if failedpublic final String toString(Object item)
JsonGenerator.serialize(Object)
.
item
- data key/value pairs
public final String toPrettyString(Object item)
JsonGenerator.serialize(Object)
with JsonGenerator.enablePrettyPrint()
.
The specifics of how the JSON representation is made pretty is implementation dependent, and
should not be relied on. However, it is assumed to be legal, and in fact differs from
toString(Object)
only by adding whitespace that does not change its meaning.
item
- data key/value pairs
public final byte[] toByteArray(Object item)
JsonGenerator.serialize(Object)
.
item
- data key/value pairs
public final <T> T fromString(String value, Class<T> destinationClass) throws IOException
JsonParser.parse(Class, CustomizeJsonParser)
.
value
- JSON string valuedestinationClass
- destination class that has an accessible default constructor to use to
create a new instance
IOException
public final <T> T fromInputStream(InputStream inputStream, Class<T> destinationClass) throws IOException
JsonParser.parseAndClose(Class, CustomizeJsonParser)
.
inputStream
- JSON value in an input streamdestinationClass
- destination class that has an accessible default constructor to use to
create a new instance
IOException
public final <T> T fromReader(Reader reader, Class<T> destinationClass) throws IOException
JsonParser.parseAndClose(Class, CustomizeJsonParser)
.
reader
- JSON value in a readerdestinationClass
- destination class that has an accessible default constructor to use to
create a new instance
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |