Package com.google.api.client.json
Class GenericJson
- java.lang.Object
-
- java.util.AbstractMap<java.lang.String,java.lang.Object>
-
- com.google.api.client.util.GenericData
-
- com.google.api.client.json.GenericJson
-
- All Implemented Interfaces:
java.lang.Cloneable,java.util.Map<java.lang.String,java.lang.Object>
- Direct Known Subclasses:
AbstractJsonFactoryTest.AnimalGenericJson,AbstractJsonFactoryTest.ExtendsGenericJson,JsonWebToken.Header,JsonWebToken.Payload
public class GenericJson extends GenericData implements java.lang.Cloneable
Generic JSON data that stores all unknown key name/value pairs.Subclasses can declare fields for known data keys using the
Keyannotation. Each field can be of any visibility (private, package private, protected, or public) and must not be static.nullunknown data key names are not allowed, butnulldata values are allowed.Implementation is not thread-safe. For a thread-safe choice instead use an implementation of
ConcurrentMap.- Since:
- 1.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.api.client.util.GenericData
GenericData.Flags
-
-
Field Summary
Fields Modifier and Type Field Description private JsonFactoryjsonFactoryJSON factory ornullfor none.
-
Constructor Summary
Constructors Constructor Description GenericJson()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GenericJsonclone()Makes a "deep" clone of the generic data, in which the clone is completely independent of the original.JsonFactorygetFactory()Returns the JSON factory ornullfor none.GenericJsonset(java.lang.String fieldName, java.lang.Object value)Sets the given field value (may benull) for the given field name.voidsetFactory(JsonFactory factory)Sets the JSON factory ornullfor none.java.lang.StringtoPrettyString()Returns a pretty-printed serialized JSON string representation ortoString()ifgetFactory()isnull.java.lang.StringtoString()-
Methods inherited from class com.google.api.client.util.GenericData
entrySet, get, getClassInfo, getUnknownKeys, put, putAll, remove, setUnknownKeys
-
Methods inherited from class java.util.AbstractMap
clear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, size, values
-
-
-
-
Field Detail
-
jsonFactory
private JsonFactory jsonFactory
JSON factory ornullfor none.
-
-
Method Detail
-
getFactory
public final JsonFactory getFactory()
Returns the JSON factory ornullfor none.- Since:
- 1.6
-
setFactory
public final void setFactory(JsonFactory factory)
Sets the JSON factory ornullfor none.- Since:
- 1.6
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.AbstractMap<java.lang.String,java.lang.Object>
-
toPrettyString
public java.lang.String toPrettyString() throws java.io.IOExceptionReturns a pretty-printed serialized JSON string representation ortoString()ifgetFactory()isnull.- Throws:
java.io.IOException- Since:
- 1.6
-
clone
public GenericJson clone()
Description copied from class:GenericDataMakes a "deep" clone of the generic data, in which the clone is completely independent of the original.- Overrides:
clonein classGenericData
-
set
public GenericJson set(java.lang.String fieldName, java.lang.Object value)
Description copied from class:GenericDataSets the given field value (may benull) for the given field name. Any existing value for the field will be overwritten. It may be more slightly more efficient thanGenericData.put(String, Object)because it avoids accessing the field's original value.Overriding is only supported for the purpose of calling the super implementation and changing the return type, but nothing else.
- Overrides:
setin classGenericData
-
-