public class JsonUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
CONFIDENTIAL_PROPERTY_SET |
static String |
CONFIDENTIAL_PROPERTY_UNSET |
| Modifier and Type | Method and Description |
|---|---|
static javax.json.JsonObject |
accumalate(javax.json.JsonObject jsonObject,
String key,
javax.json.JsonValue value)
Puts a value into a
JsonObject with the specified key. |
static int |
getInt(javax.json.JsonObject jsonObject,
String key,
int dflt)
Gets an integer from a
JsonObject |
static javax.json.JsonObject |
getJsonForRestModel(RestModel model,
boolean hideConfidentialProperties) |
static javax.json.JsonValue |
getJsonObject(Object object,
boolean hideConfidentialProperties)
Deprecated.
As of 5.0, replaced by
getJsonValue(Object) as a more accurately named method
with the removal of Jettison the return value is no longer JSONObject but JsonValue. |
static javax.json.JsonValue |
getJsonValue(Object object)
Converts an object to a JsonValue
|
static javax.json.JsonValue |
getJsonValue(Object object,
boolean hideConfidentialProperties)
Converts an object to a JsonValue
|
static String |
getString(javax.json.JsonObject jsonObject,
String key,
String dflt)
Gets a String from a
JsonObject |
static boolean |
isConfidentialProperty(Class clazz,
String getterMethodName) |
static List<Object> |
jsonArraytoArray(javax.json.JsonArray array)
|
static Map<String,Object> |
jsonObjectToMap(javax.json.JsonObject object)
|
static Object |
jsonValueToRaw(javax.json.JsonValue value)
Converts a JsonValue to the java standard type it represents.
|
static javax.json.JsonArray |
processCollection(Collection c)
|
static javax.json.JsonObject |
processMap(Map map) |
public static final String CONFIDENTIAL_PROPERTY_SET
public static final String CONFIDENTIAL_PROPERTY_UNSET
public static javax.json.JsonValue getJsonValue(Object object) throws javax.json.JsonException
The object must be one of JsonValue, Collection, Map, ResponseBody, String,
Integer, Long, Double, Boolean, BigInteger, BigDecimal,
a class that has a REST model or an array of one of the above.
object - The object to convertjavax.json.JsonException - If the object cannot be converted to a JsonValuepublic static javax.json.JsonValue getJsonValue(Object object, boolean hideConfidentialProperties) throws javax.json.JsonException
The object must be one of JsonValue, Collection, Map, ResponseBody, String,
Integer, Long, Double, Boolean, BigInteger, BigDecimal,
a class that has a REST model or an array of one of the above.
object - The object to converthideConfidentialProperties - javax.json.JsonException - If the object cannot be converted to a JsonValue@Deprecated public static javax.json.JsonValue getJsonObject(Object object, boolean hideConfidentialProperties) throws javax.json.JsonException
getJsonValue(Object) as a more accurately named method
with the removal of Jettison the return value is no longer JSONObject but JsonValue.
The object must be one of JsonValue, Collection, Map, ResponseBody, String,
Integer, Long, Double, Boolean, BigInteger, BigDecimal,
a class that has a REST model or an array of one of the above.
object - The object to converthideConfidentialProperties - javax.json.JsonException - If the object cannot be converted to a JsonValuepublic static javax.json.JsonObject getJsonForRestModel(RestModel model, boolean hideConfidentialProperties)
public static boolean isConfidentialProperty(Class clazz, String getterMethodName)
public static javax.json.JsonArray processCollection(Collection c) throws javax.json.JsonException
c - javax.json.JsonExceptionpublic static javax.json.JsonObject processMap(Map map) throws javax.json.JsonException
javax.json.JsonExceptionpublic static String getString(javax.json.JsonObject jsonObject, String key, String dflt)
JsonObjectjsonObject - key - dflt - returned if there is no mapping for the keypublic static int getInt(javax.json.JsonObject jsonObject,
String key,
int dflt)
JsonObjectjsonObject - key - dflt - returned if there is no mapping for the keypublic static javax.json.JsonObject accumalate(javax.json.JsonObject jsonObject,
String key,
javax.json.JsonValue value)
JsonObject with the specified key.
If the key already exists then a JsonArray is used to store all the values. This differs to Map.put(Object, Object)
as put replaces the value if the key already exists.
jsonObject - key - value - public static Map<String,Object> jsonObjectToMap(javax.json.JsonObject object)
JsonObject to a Map<String, Object>
where the values of all of the basic type (Integer, String etc.), and not JsonValue.object - The JsonObject to convert to a MapjsonValueToRaw(javax.json.JsonValue)public static List<Object> jsonArraytoArray(javax.json.JsonArray array)
JsonArray to a List<Object>
where the objects are all the standard java types represented by the values
in the arrayarray - The JsonArray to convert to ListjsonValueToRaw(javax.json.JsonValue)public static Object jsonValueToRaw(javax.json.JsonValue value)
JsonArray -> List<Object>
JsonObject -> Map<String, Object>
JsonString -> String
JsonNumber -> BigDecimal
JsonValue.TRUE -> Boolean.TRUE
JsonValue.FALSE -> Boolean.FALSE
JsonValue.NULL -> null
value - JsonValueCopyright © 2019. All rights reserved.