Class JsonObjectParser (1.42.3)

public class JsonObjectParser implements ObjectParser

Parses JSON data into an data class of key/value pairs.

Implementation is thread-safe.

Sample usage:

 
 static void setParser(HttpRequest request) {
 request.setParser(new JsonObjectParser(new JacksonFactory()));
 }
 
 

Inheritance

Object > JsonObjectParser

Implements

ObjectParser

Constructors

JsonObjectParser(JsonFactory jsonFactory)

public JsonObjectParser(JsonFactory jsonFactory)
Parameter
NameDescription
jsonFactoryJsonFactory

JSON factory

JsonObjectParser(JsonObjectParser.Builder builder)

protected JsonObjectParser(JsonObjectParser.Builder builder)
Parameter
NameDescription
builderJsonObjectParser.Builder

builder

Methods

<T>parseAndClose(InputStream in, Charset charset, Class<T> dataClass)

public T <T>parseAndClose(InputStream in, Charset charset, Class<T> dataClass)

Parses the given input stream into a new instance of the the given data class of key/value pairs and closes the input stream.

Parameters
NameDescription
inInputStream
charsetCharset
dataClassClass<T>
Returns
TypeDescription
T
Exceptions
TypeDescription
IOException

<T>parseAndClose(Reader reader, Class<T> dataClass)

public T <T>parseAndClose(Reader reader, Class<T> dataClass)

Parses the given reader into a new instance of the the given data class of key/value pairs and closes the reader.

Parameters
NameDescription
readerReader
dataClassClass<T>
Returns
TypeDescription
T
Exceptions
TypeDescription
IOException

getJsonFactory()

public final JsonFactory getJsonFactory()

Returns the JSON factory.

Returns
TypeDescription
JsonFactory

getWrapperKeys()

public Set<String> getWrapperKeys()

Returns the unmodifiable set of wrapper keys for the JSON content.

Returns
TypeDescription
Set<String>

parseAndClose(InputStream in, Charset charset, Type dataType)

public Object parseAndClose(InputStream in, Charset charset, Type dataType)

Parses the given input stream into a new instance of the the given data type of key/value pairs and closes the input stream.

Parameters
NameDescription
inInputStream
charsetCharset
dataTypeType
Returns
TypeDescription
Object
Exceptions
TypeDescription
IOException

parseAndClose(Reader reader, Type dataType)

public Object parseAndClose(Reader reader, Type dataType)

Parses the given reader into a new instance of the the given data type of key/value pairs and closes the reader.

Parameters
NameDescription
readerReader
dataTypeType
Returns
TypeDescription
Object
Exceptions
TypeDescription
IOException