# Class JsonObjectParser (2.1.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.1.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonObjectParser)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.json.JsonObjectParser)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.json.JsonObjectParser)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.json.JsonObjectParser)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.json.JsonObjectParser)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.json.JsonObjectParser)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.json.JsonObjectParser)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.json.JsonObjectParser)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.json.JsonObjectParser)

    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](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> JsonObjectParser

## Implements

[ObjectParser](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.ObjectParser)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Constructors

### JsonObjectParser(JsonFactory jsonFactory)

    public JsonObjectParser(JsonFactory jsonFactory)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `jsonFactory` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonFactory` JSON factory |

### JsonObjectParser(JsonObjectParser.Builder builder)

    protected JsonObjectParser(JsonObjectParser.Builder builder)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `builder` | `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonObjectParser.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** ||
|---|---|
| **Name** | **Description** |
| `in` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` |
| `charset` | `https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html` |
| `dataClass` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html<T>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### \<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** ||
|---|---|
| **Name** | **Description** |
| `reader` | `https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html` |
| `dataClass` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html<T>` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### getJsonFactory()

    public final JsonFactory getJsonFactory()

Returns the JSON factory.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonFactory` |   |

### getWrapperKeys()

    public Set<String> getWrapperKeys()

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Set.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |   |

### 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** ||
|---|---|
| **Name** | **Description** |
| `in` | `https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html` |
| `charset` | `https://docs.oracle.com/javase/8/docs/api/java/nio/charset/Charset.html` |
| `dataType` | `https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### 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** ||
|---|---|
| **Name** | **Description** |
| `reader` | `https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html` |
| `dataType` | `https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Type.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |   |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |