public class JsonObjectParser extends Objectimplements ObjectParser
Implementation is thread-safe.
Sample usage:
static void setParser(HttpRequest request) {
request.setParser(new JsonObjectParser(new JacksonFactory()));
}
| Modifier and Type | Class and Description |
|---|---|
static class |
JsonObjectParser
Builder.
|
| Modifier | Constructor and Description |
|---|---|
|
JsonObjectParser(JsonFactory
|
protected |
JsonObjectParser(JsonObjectParser
|
| Modifier and Type | Method and Description |
|---|---|
JsonFactory |
getJsonFactory()
Returns the JSON factory.
|
Set |
getWrapperKeys()
Returns the unmodifiable set of wrapper keys for the JSON content.
|
<T> T |
parseAndClose(InputStream
Parses the given input stream into a new instance of the the given data class of key/value pairs and closes the input stream.
|
Object |
parseAndClose(InputStream
Parses the given input stream into a new instance of the the given data type of key/value pairs and closes the input stream.
|
<T> T |
parseAndClose(Reader
Parses the given reader into a new instance of the the given data class of key/value pairs and closes the reader.
|
Object |
parseAndClose(Reader
Parses the given reader into a new instance of the the given data type of key/value pairs and closes the reader.
|
public JsonObjectParser(JsonFactoryjsonFactory)
jsonFactory - JSON factory
protected JsonObjectParser(JsonObjectParser.Builder builder)
builder - builder
public <T> T parseAndClose(InputStreamin, Charset charset, Class <T> dataClass) throws IOException
ObjectParser
parseAndClose in interface
ObjectParser
in - input stream which contains the data to parse
charset - charset which should be used to decode the input stream or
null if unknown
dataClass - class into which the data is parsed
IOException
public ObjectparseAndClose(InputStream in, Charset charset, Type dataType) throws IOException
ObjectParser
parseAndClose in interface
ObjectParser
in - input stream which contains the data to parse
charset - charset which should be used to decode the input stream or
null if unknown
dataType - type into which the data is parsed
IOException
public <T> T parseAndClose(Readerreader, Class <T> dataClass) throws IOException
ObjectParser
parseAndClose in interface
ObjectParser
reader - reader which contains the text data to parse
dataClass - class into which the data is parsed
IOException
public ObjectparseAndClose(Reader reader, Type dataType) throws IOException
ObjectParser
parseAndClose in interface
ObjectParser
reader - reader which contains the text data to parse
dataType - type into which the data is parsed
IOException
public final JsonFactorygetJsonFactory()