# Package com.google.api.client.json (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)
- [2.0.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/2.0.3/com.google.api.client.json)
- [1.47.1](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.47.1/com.google.api.client.json)
- [1.46.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.46.3/com.google.api.client.json)
- [1.45.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.45.3/com.google.api.client.json)
- [1.44.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.44.2/com.google.api.client.json)
- [1.43.2](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.43.2/com.google.api.client.json)
- [1.42.3](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.42.3/com.google.api.client.json)
- [1.41.8](https://docs.cloud.google.com/java/docs/reference/google-http-client/1.41.8/com.google.api.client.json)
Utilities for JSON as specified in [RFC 4627: The
application/json Media Type for JavaScript Object Notation (JSON)](http://tools.ietf.org/html/rfc4627) and [Introducing JSON](http://json.org/).

## Classes

### [CustomizeJsonParser](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.CustomizeJsonParser)

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

Customizes the behavior of a JSON parser.

All methods have a default trivial implementation, so subclasses need only implement the
methods whose behavior needs customization.

Implementation has no fields and therefore thread-safe, but sub-classes are not necessarily
thread-safe.

### [GenericJson](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.GenericJson)

Generic JSON data that stores all unknown key name/value pairs.

Subclasses can declare fields for known data keys using the [Key](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Key) annotation. Each field
can be of any visibility (private, package private, protected, or public) and must not be static.
`null` unknown data key names are not allowed, but `null` data values are allowed.

Implementation is not thread-safe. For a thread-safe choice instead use an implementation of
ConcurrentMap.

### [Json](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.Json)

JSON utilities.

### [JsonFactory](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.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.

### [JsonGenerator](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonGenerator)

Abstract low-level JSON serializer.

Implementation has no fields and therefore thread-safe, but sub-classes are not necessarily
thread-safe.

### [JsonObjectParser](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonObjectParser)

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()));
     }
     
     
### [JsonObjectParser.Builder](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonObjectParser.Builder)

Builder.

Implementation is not thread-safe.

### [JsonParser](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonParser)

Abstract low-level JSON parser. See <https://developers.google.com/api-client-library/java/google-http-java-client/json>

Implementation has no fields and therefore thread-safe, but sub-classes are not necessarily
thread-safe.

If a JSON map is encountered while using a destination class of type Map, then an java.util.ArrayMap is used by default for the parsed values.

## Enums

### [JsonToken](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonToken)

JSON token in the low-level JSON library.

## Annotation Types

### [JsonPolymorphicTypeMap](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonPolymorphicTypeMap)

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

Declares that the data type enclosing this field is polymorphic, and that the value of this field
in a heterogeneous JSON schema will determine what type the data should be parsed into.

A data structure must have no more than one field with this annotation present. The annotated
field's type must be considered "primitive" by [Data#isPrimitive(Type)](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.util.Data#com_google_api_client_util_Data_isPrimitive_java_lang_reflect_Type_). The field's value
will be compared against the [TypeDef#key()](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonPolymorphicTypeMap.TypeDef#com_google_api_client_json_JsonPolymorphicTypeMap_TypeDef_key_) using [Object#toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--).

### [JsonPolymorphicTypeMap.TypeDef](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonPolymorphicTypeMap.TypeDef)

Declares a mapping between a key value and a referenced class.

### [JsonString](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonString)

Use this annotation to specify that a declared numeric Java field should map to a JSON string.

By default declared Java numeric fields are stored as JSON numbers. For example:

     
     class A {
     @Key BigInteger value;
     }
     
     
can be used for this JSON content:

     
     {"value" : 12345768901234576890123457689012345768901234576890}
     
     
However, if instead the JSON content uses a JSON String to store the value, one needs to use
the [JsonString](https://docs.cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonString) annotation. For example:

     
     class B {
     @Key @JsonString BigInteger value;
     }
     
     
can be used for this JSON content:

     
     {"value" : "12345768901234576890123457689012345768901234576890"}