Package me.hsgamer.hscore.gson
Class GsonUtils
java.lang.Object
me.hsgamer.hscore.gson.GsonUtils
Some utilities for Gson
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<com.google.gson.JsonElement> getElements(com.google.gson.JsonArray array) Get the elements from aJsonArraygetElements(com.google.gson.JsonObject object) Get the elements from aJsonObjectstatic booleanisEmpty(com.google.gson.JsonArray array) Check if theJsonArrayis emptystatic Objectnormalize(com.google.gson.JsonElement element, boolean deep) Normalize theJsonElementto the objectstatic com.google.gson.JsonElementparse(com.google.gson.stream.JsonReader reader) Parse a reader toJsonElementstatic com.google.gson.JsonElementParse a reader toJsonElementstatic com.google.gson.JsonElementParse a string toJsonElement
-
Method Details
-
parse
Parse a string toJsonElement- Parameters:
string- the string- Returns:
- the
JsonElement
-
parse
Parse a reader toJsonElement- Parameters:
reader- the reader- Returns:
- the
JsonElement
-
parse
public static com.google.gson.JsonElement parse(com.google.gson.stream.JsonReader reader) Parse a reader toJsonElement- Parameters:
reader- the reader- Returns:
- the
JsonElement
-
getElements
Get the elements from aJsonArray- Parameters:
array- the array- Returns:
- the elements
-
isEmpty
public static boolean isEmpty(com.google.gson.JsonArray array) Check if theJsonArrayis empty- Parameters:
array- the array- Returns:
- true if it is empty
-
getElements
public static Map<String,com.google.gson.JsonElement> getElements(com.google.gson.JsonObject object) Get the elements from aJsonObject- Parameters:
object- the object- Returns:
- the elements
-
normalize
Normalize theJsonElementto the object- Parameters:
element- the elementdeep- whether to normalize the nested elements- Returns:
- the normalized object
-