Introduction
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)
Syntax
- 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)