Android Gson


Gson is a Java library that can be used to convert Java Objects into their JSON representation. Gson considers both of these as very important design goals.

Gson Features:

Provide simple toJson() and fromJson() methods to convert Java objects to JSON and vice-versa

Allow pre-existing unmodifiable objects to be converted to and from JSON

Extensive support of Java Generics

Support arbitrarily complex objects (with deep inheritance hierarchies and extensive use of generic types)


  • Excluder excluder()
  • FieldNamingStrategy fieldNamingStrategy()
  • <T> T fromJson(JsonElement json, Class<T> classOfT)
  • <T> T fromJson(JsonElement json, Type typeOfT)
  • <T> T fromJson(JsonReader reader, Type typeOfT)
  • <T> T fromJson(Reader json, Class<T> classOfT)
  • <T> T fromJson(Reader json, Type typeOfT)
  • <T> T fromJson(String json, Class<T> classOfT)
  • <T> T fromJson(String json, Type typeOfT)
  • <T> TypeAdapter<T> getAdapter(Class<T> type)
  • <T> TypeAdapter<T> getAdapter(TypeToken<T> type)
  • <T> TypeAdapter<T> getDelegateAdapter(TypeAdapterFactory skipPast, TypeToken<T> type)
  • JsonReader newJsonReader(Reader reader)
  • JsonWriter newJsonWriter(Writer writer)
  • JsonElement toJsonTree(Object src)
  • JsonElement toJsonTree(Object src, Type typeOfSrc)
  • boolean serializeNulls()
  • boolean htmlSafe()
  • String toJson(JsonElement jsonElement)
  • String toJson(Object src)
  • String toJson(Object src, Type typeOfSrc)
  • String toString()
  • void toJson(Object src, Type typeOfSrc, Appendable writer)
  • void toJson(Object src, Type typeOfSrc, JsonWriter writer)
  • void toJson(JsonElement jsonElement, Appendable writer)
  • void toJson(JsonElement jsonElement, JsonWriter writer)
  • void toJson(Object src, Appendable writer)