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.
Sets the given field value (may be null) for the given field name. Any existing value
for the field will be overwritten. It may be more slightly more efficient than #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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-13 UTC."],[],[],null,["# Class GenericJson (2.0.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.0.0 (latest)](/java/docs/reference/google-http-client/latest/com.google.api.client.json.GenericJson)\n- [1.47.1](/java/docs/reference/google-http-client/1.47.1/com.google.api.client.json.GenericJson)\n- [1.46.3](/java/docs/reference/google-http-client/1.46.3/com.google.api.client.json.GenericJson)\n- [1.45.3](/java/docs/reference/google-http-client/1.45.3/com.google.api.client.json.GenericJson)\n- [1.44.2](/java/docs/reference/google-http-client/1.44.2/com.google.api.client.json.GenericJson)\n- [1.43.2](/java/docs/reference/google-http-client/1.43.2/com.google.api.client.json.GenericJson)\n- [1.42.3](/java/docs/reference/google-http-client/1.42.3/com.google.api.client.json.GenericJson)\n- [1.41.8](/java/docs/reference/google-http-client/1.41.8/com.google.api.client.json.GenericJson) \n\n public class GenericJson extends GenericData implements Cloneable\n\nGeneric JSON data that stores all unknown key name/value pairs.\n\nSubclasses can declare fields for known data keys using the [Key](/java/docs/reference/google-http-client/latest/com.google.api.client.util.Key) annotation. Each field\ncan be of any visibility (private, package private, protected, or public) and must not be static.\n`null` unknown data key names are not allowed, but `null` data values are allowed.\n\nImplementation is not thread-safe. For a thread-safe choice instead use an implementation of\nConcurrentMap. \n\nInheritance\n-----------\n\n[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e [AbstractMap](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html) \\\u003e [GenericData](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData) \\\u003e GenericJson \n\nImplements\n----------\n\n[Cloneable](https://docs.oracle.com/javase/8/docs/api/java/lang/Cloneable.html) \n\nInherited Members\n-----------------\n\n[GenericData.clone()](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_clone__) \n[GenericData.entrySet()](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_entrySet__) \n[GenericData.equals(Object)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_equals_java_lang_Object_) \n[GenericData.get(Object)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_get_java_lang_Object_) \n[GenericData.getClassInfo()](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_getClassInfo__) \n[GenericData.getUnknownKeys()](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_getUnknownKeys__) \n[GenericData.hashCode()](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_hashCode__) \n[GenericData.put(String,Object)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_put_java_lang_String_java_lang_Object_) \n[GenericData.putAll(Map\\\u003c? extends String,?\\\u003e)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_putAll_java_util_Map___extends_java_lang_String____) \n[GenericData.remove(Object)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_remove_java_lang_Object_) \n[GenericData.set(String,Object)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_set_java_lang_String_java_lang_Object_) \n[GenericData.setUnknownKeys(Map\\\u003cString,Object\\\u003e)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_setUnknownKeys_java_util_Map_java_lang_String_java_lang_Object__) \n[GenericData.toString()](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_toString__) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-) \n[AbstractMap.clear()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#clear--) \n[AbstractMap.containsKey(Object)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#containsKey-java.lang.Object-) \n[AbstractMap.containsValue(Object)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#containsValue-java.lang.Object-) \n[AbstractMap.isEmpty()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#isEmpty--) \n[AbstractMap.keySet()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#keySet--) \n[AbstractMap.put(K,V)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#put-K-V-) \n[AbstractMap.putAll(Map\\\u003c? extends K,? extends V\\\u003e)](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#putAll-java.util.Map\u003c? extends K-? extends V\u003e-) \n[AbstractMap.size()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#size--) \n[AbstractMap.values()](https://docs.oracle.com/javase/8/docs/api/java/util/AbstractMap.html#values--)\n\nConstructors\n------------\n\n### GenericJson()\n\n public GenericJson()\n\nMethods\n-------\n\n### clone()\n\n public GenericJson clone()\n\nMakes a \"deep\" clone of the generic data, in which the clone is completely independent of the\noriginal.\n\n**Overrides** \n[GenericData.clone()](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_clone__)\n\n### getFactory()\n\n public final JsonFactory getFactory()\n\nReturns the JSON factory or `null` for none.\n\n### set(String fieldName, Object value)\n\n public GenericJson set(String fieldName, Object value)\n\nSets the given field value (may be `null`) for the given field name. Any existing value\nfor the field will be overwritten. It may be more slightly more efficient than #put(String, Object) because it avoids accessing the field's original value.\n\nOverriding is only supported for the purpose of calling the super implementation and\nchanging the return type, but nothing else.\n\n**Overrides** \n[GenericData.set(String fieldName, Object value)](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_set_java_lang_String_java_lang_Object_)\n\n### setFactory(JsonFactory factory)\n\n public final void setFactory(JsonFactory factory)\n\nSets the JSON factory or `null` for none.\n\n### toPrettyString()\n\n public String toPrettyString()\n\nReturns a pretty-printed serialized JSON string representation or [#toString()](/java/docs/reference/google-http-client/latest/com.google.api.client.json.GenericJson#com_google_api_client_json_GenericJson_toString__) if [#getFactory()](/java/docs/reference/google-http-client/latest/com.google.api.client.json.GenericJson#com_google_api_client_json_GenericJson_getFactory__) is `null`.\n\n### toString()\n\n public String toString()\n\n**Overrides** \n[GenericData.toString()](/java/docs/reference/google-http-client/latest/com.google.api.client.util.GenericData#com_google_api_client_util_GenericData_toString__)"]]