public class GsonFactory extends JsonFactory
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 and Description |
---|
GsonFactory() |
Modifier and Type | Method and Description |
---|---|
JsonGenerator |
createJsonGenerator(OutputStream out,
Charset enc)
Returns a new instance of a low-level JSON serializer for the given output stream and encoding.
|
JsonGenerator |
createJsonGenerator(Writer writer)
Returns a new instance of a low-level JSON serializer for the given writer.
|
JsonParser |
createJsonParser(InputStream in)
Returns a new instance of a low-level JSON parser for the given input stream.
|
JsonParser |
createJsonParser(InputStream in,
Charset charset)
Returns a new instance of a low-level JSON parser for the given input stream.
|
JsonParser |
createJsonParser(Reader reader)
Returns a new instance of a low-level JSON parser for the given reader.
|
JsonParser |
createJsonParser(String value)
Returns a new instance of a low-level JSON parser for the given string value.
|
static GsonFactory |
getDefaultInstance()
Beta Returns a global thread-safe instance. |
createJsonObjectParser, fromInputStream, fromInputStream, fromReader, fromString, toByteArray, toPrettyString, toString
@Beta public static GsonFactory getDefaultInstance()
Beta
public JsonParser createJsonParser(InputStream in)
JsonFactory
createJsonParser
in class JsonFactory
in
- input streampublic JsonParser createJsonParser(InputStream in, Charset charset)
JsonFactory
createJsonParser
in class JsonFactory
in
- input streamcharset
- charset in which the input stream is encoded or null
to let the parser
detect the charsetpublic JsonParser createJsonParser(String value)
JsonFactory
createJsonParser
in class JsonFactory
value
- string valuepublic JsonParser createJsonParser(Reader reader)
JsonFactory
createJsonParser
in class JsonFactory
reader
- readerpublic JsonGenerator createJsonGenerator(OutputStream out, Charset enc)
JsonFactory
createJsonGenerator
in class JsonFactory
out
- output streamenc
- encodingpublic JsonGenerator createJsonGenerator(Writer writer)
JsonFactory
createJsonGenerator
in class JsonFactory
writer
- writerCopyright © 2011–2022 Google. All rights reserved.