public class JsonUtil extends Object
Constructor and Description |
---|
JsonUtil() |
Modifier and Type | Method and 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 a
List from . |
static <K,T> List<T> |
getListValues(org.json.JSONObject object,
String key,
java.util.function.Function<K,T> parserItem)
Returns a
List from . |
static boolean |
hasValue(org.json.JSONObject obj,
String key)
Returns whether the given JSON object has a value for the given key.
|
public static <T> T getJSONInnerObject(org.json.JSONObject obj, String propertyName, boolean isRequired, Class<T> desiredClass)
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.public static <T> List<T> getListValues(org.json.JSONObject object, String key)
List
from . always stores a JSONArray
instead List
.
So, this method create a new List
, puts all items from JSONArray
and returns.object
- the JSON owner.key
- the key property of list.List
from .public static <K,T> List<T> getListValues(org.json.JSONObject object, String key, java.util.function.Function<K,T> parserItem)
public static boolean hasValue(org.json.JSONObject obj, String key)
obj
- the objectkey
- the desired keyLumisXP 12.3.0.200408 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.