Package org.aksw.commons.util.gson
Class GsonUtils
java.lang.Object
org.aksw.commons.util.gson.GsonUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.gson.JsonElementcopyOrNull(com.google.gson.JsonElement elt) Returns null if the argument is null, otherwise a deep copy.static booleanisNull(com.google.gson.JsonElement elt) Returns true if the argument is either java null or json null.static com.google.gson.JsonObjectCreates fresh empty JSON objects if a key has no valuestatic com.google.gson.JsonObjectstatic com.google.gson.JsonArraymerge(com.google.gson.JsonArray a, com.google.gson.JsonArray b) static com.google.gson.JsonElementmerge(com.google.gson.JsonElement a, com.google.gson.JsonElement b) static com.google.gson.JsonElementmerge(com.google.gson.JsonObject a, com.google.gson.JsonObject b) parsePathSegments(String str) This method is a stub.static com.google.gson.JsonObjectsetElement(com.google.gson.JsonObject obj, List<String> keys, com.google.gson.JsonElement value) Set an element at a given path.static com.google.gson.JsonObjectstatic com.google.gson.JsonObjectSet a string at a given path.
-
Constructor Details
-
GsonUtils
public GsonUtils()
-
-
Method Details
-
setString
public static com.google.gson.JsonObject setString(com.google.gson.JsonObject obj, List<String> keys, String value) Set a string at a given path. Creates intermediate json objects as needed. A null value creates the path but removes the last key. -
setNumber
-
setElement
public static com.google.gson.JsonObject setElement(com.google.gson.JsonObject obj, List<String> keys, com.google.gson.JsonElement value) Set an element at a given path. Creates intermediate json objects as needed. A null value creates the path but removes the last key. -
makePath
Creates fresh empty JSON objects if a key has no value -
makePath
-
parsePathSegments
This method is a stub. Currently it only splits by '.'. It should later also support array access syntax such as foo.bar["baz"] -
merge
public static com.google.gson.JsonElement merge(com.google.gson.JsonElement a, com.google.gson.JsonElement b) -
merge
public static com.google.gson.JsonElement merge(com.google.gson.JsonObject a, com.google.gson.JsonObject b) -
merge
public static com.google.gson.JsonArray merge(com.google.gson.JsonArray a, com.google.gson.JsonArray b) -
isNull
public static boolean isNull(com.google.gson.JsonElement elt) Returns true if the argument is either java null or json null. -
copyOrNull
public static com.google.gson.JsonElement copyOrNull(com.google.gson.JsonElement elt) Returns null if the argument is null, otherwise a deep copy.
-