public class JsonUtils extends Object
| Constructor | Description |
|---|---|
JsonUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static void |
addTypeAdapterDeserializer(Class type,
com.google.gson.JsonDeserializer<?> jsonDeserializer) |
Add a type adapter
|
static void |
addTypeAdapterSerializer(Class type,
com.google.gson.JsonSerializer<?> jsonSerializer) |
Add a type adapter
|
static <T> T |
fromJson(String json,
Class<T> T) |
From json.
|
static com.google.gson.Gson |
getGson() |
returns gson
|
static com.google.gson.Gson |
getGson(com.google.gson.ExclusionStrategy... exclusionStrategies) |
returns gson
|
static com.google.gson.Gson |
getGson(Class ignoreClass,
com.google.gson.ExclusionStrategy... exclusionStrategies) |
returns gson
|
static void |
setJsonDateFormat(String dateFormat) |
|
static String |
toJson(Object src) |
To json.
|
static String |
toJson(Object src,
com.google.gson.ExclusionStrategy... exclusionStrategies) |
To json.
|
public static com.google.gson.Gson getGson()
public static com.google.gson.Gson getGson(com.google.gson.ExclusionStrategy... exclusionStrategies)
exclusionStrategies - strategy to usepublic static com.google.gson.Gson getGson(Class ignoreClass, com.google.gson.ExclusionStrategy... exclusionStrategies)
ignoreClass - class to ignoreexclusionStrategies - strategy to usepublic static void addTypeAdapterDeserializer(Class type, com.google.gson.JsonDeserializer<?> jsonDeserializer)
type - the type (@Class) we're adaptingjsonDeserializer - the type's deserializerpublic static void addTypeAdapterSerializer(Class type, com.google.gson.JsonSerializer<?> jsonSerializer)
type - the type (@Class) we're adaptingjsonSerializer - the type's deserializerpublic static <T> T fromJson(String json, Class<T> T)
T - the generic typejson - the string from which the object is to be deserialized.T - the type of the desired object.Gson.fromJson(String, Class)public static String toJson(Object src)
src - the object for which Json representation is to be created
setting for Gson .Gson.toJson(Object)public static String toJson(Object src, com.google.gson.ExclusionStrategy... exclusionStrategies)
src - the object for which Json representation is to be created
setting for Gson .Gson.toJson(Object)public static void setJsonDateFormat(String dateFormat)
Copyright © 2018. All rights reserved.