Package lumis.util
Class JsonUtil
- java.lang.Object
-
- lumis.util.JsonUtil
-
public class JsonUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description JsonUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> T
getJSONInnerObject(org.json.JSONObject obj, String propertyName, boolean isRequired, Class<T> desiredClass)
Returns an inner object of the given JSON as an instance of the given desired class.static <T> List<T>
getListValues(org.json.JSONObject object, String key)
Returns aList
from .static <K,T>
List<T>getListValues(org.json.JSONObject object, String key, java.util.function.Function<K,T> parserItem)
Returns aList
from .static boolean
hasValue(org.json.JSONObject obj, String key)
Returns whether the given JSON object has a value for the given key.
-
-
-
Method Detail
-
getJSONInnerObject
public static <T> T getJSONInnerObject(org.json.JSONObject obj, String propertyName, boolean isRequired, Class<T> desiredClass)
Returns an inner object of the given JSON as an instance of the given desired class.- Parameters:
obj
- the JSON object to get inner object.propertyName
- the property name.isRequired
- indicates whether the object is required.desiredClass
- the object desired class to be returned.- Returns:
- an inner object of the given JSON as an instance of the given desired class.
- Since:
- 11.0.0
-
getListValues
public static <T> List<T> getListValues(org.json.JSONObject object, String key)
Returns aList
from . always stores aJSONArray
insteadList
. So, this method create a newList
, puts all items fromJSONArray
and returns.- Parameters:
object
- the JSON owner.key
- the key property of list.- Returns:
- a
List
from . - Since:
- 12.0.0
-
getListValues
public static <K,T> List<T> getListValues(org.json.JSONObject object, String key, java.util.function.Function<K,T> parserItem)
-
hasValue
public static boolean hasValue(org.json.JSONObject obj, String key)
Returns whether the given JSON object has a value for the given key.- Parameters:
obj
- the objectkey
- the desired key- Returns:
- whether the given JSON object has a value for the given key.
- Since:
- 12.0.0
-
-