Package com.google.api.client.json (1.45.2)

Classes

CustomizeJsonParser

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

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

Subclasses can declare fields for known data keys using the 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

JSON utilities.

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

Abstract low-level JSON serializer.

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

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

Builder.

Implementation is not thread-safe.

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

JSON token in the low-level JSON library.

Annotation Types

JsonPolymorphicTypeMap

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). The field's value will be compared against the TypeDef#key() using Object#toString().

JsonPolymorphicTypeMap.TypeDef

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

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 annotation. For example:

 
 class B {
 @Key @JsonString BigInteger value;
 }
 
 

can be used for this JSON content:

 
 {"value" : "12345768901234576890123457689012345768901234576890"}