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 aJsonArray
getElements
(com.google.gson.JsonObject object) Get the elements from aJsonObject
static boolean
isEmpty
(com.google.gson.JsonArray array) Check if theJsonArray
is emptystatic Object
normalize
(com.google.gson.JsonElement element, boolean deep) Normalize theJsonElement
to the objectstatic com.google.gson.JsonElement
parse
(com.google.gson.stream.JsonReader reader) Parse a reader toJsonElement
static com.google.gson.JsonElement
Parse a reader toJsonElement
static com.google.gson.JsonElement
Parse 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 theJsonArray
is 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 theJsonElement
to the object- Parameters:
element
- the elementdeep
- whether to normalize the nested elements- Returns:
- the normalized object
-