Package com.liferay.portal.kernel.json
Class JSONUtil
Object
com.liferay.portal.kernel.json.JSONUtil
- Author:
- Brian Wing Shun Chan, Rachael Koestartyo, Hugo Huijser
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addToStringCollection
(Collection<String> collection, JSONArray jsonArray) static void
addToStringCollection
(Collection<String> collection, JSONArray jsonArray, String jsonObjectKey) static JSONArray
static boolean
static boolean
equals
(JSONObject jsonObject1, JSONObject jsonObject2) static Object
static boolean
getValueAsBoolean
(Object object, String... paths) static double
getValueAsDouble
(Object object, String... paths) static int
getValueAsInt
(Object object, String... paths) static JSONArray
getValueAsJSONArray
(Object object, String... paths) static JSONObject
getValueAsJSONObject
(Object object, String... paths) static long
getValueAsLong
(Object object, String... paths) static String
getValueAsString
(Object object, String... paths) static boolean
static boolean
static boolean
isEmpty
(JSONObject jsonObject) static boolean
isJSONArray
(String json) static boolean
isJSONObject
(String json) static boolean
Deprecated.static JSONObject
merge
(JSONObject jsonObject1, JSONObject jsonObject2) static JSONArray
static JSONArray
static JSONObject
static JSONObject
static JSONArray
static JSONArray
replace
(JSONArray jsonArray, String jsonObjectKey, JSONObject newJSONObject) static <T> T[]
toArray
(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, Exception> unsafeFunction, Log log, Class<?> clazz) static <T> T[]
toArray
(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, Exception> unsafeFunction, Class<?> clazz) static <T> T[]
toArray
(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, Exception> unsafeFunction, Consumer<Exception> exceptionConsumer, Class<?> clazz) static double[]
toDoubleArray
(JSONArray jsonArray) static double[]
toDoubleArray
(JSONArray jsonArray, String jsonObjectKey) toDoubleList
(JSONArray jsonArray) toDoubleList
(JSONArray jsonArray, String jsonObjectKey) toDoubleSet
(JSONArray jsonArray) toDoubleSet
(JSONArray jsonArray, String jsonObjectKey) static float[]
toFloatArray
(JSONArray jsonArray) static float[]
toFloatArray
(JSONArray jsonArray, String jsonObjectKey) toFloatList
(JSONArray jsonArray) toFloatList
(JSONArray jsonArray, String jsonObjectKey) toFloatSet
(JSONArray jsonArray) toFloatSet
(JSONArray jsonArray, String jsonObjectKey) static int[]
toIntegerArray
(JSONArray jsonArray) static int[]
toIntegerArray
(JSONArray jsonArray, String jsonObjectKey) toIntegerList
(JSONArray jsonArray) toIntegerList
(JSONArray jsonArray, String jsonObjectKey) toIntegerSet
(JSONArray jsonArray) toIntegerSet
(JSONArray jsonArray, String jsonObjectKey) static <T> JSONArray
toJSONArray
(Collection<T> collection, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction) static <T> JSONArray
toJSONArray
(Collection<T> collection, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction, Log log) static <T> JSONArray
toJSONArray
(Collection<T> collection, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction, Consumer<Exception> exceptionConsumer) static <T> JSONArray
toJSONArray
(T[] array, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction) static <T> JSONArray
toJSONArray
(T[] array, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction, Log log) static <T> JSONArray
toJSONArray
(T[] array, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction, Consumer<Exception> exceptionConsumer) static Map<String,
JSONObject> toJSONObjectMap
(JSONArray jsonArray, String jsonObjectKey) static <T> List<T>
toList
(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, Exception> unsafeFunction) static <T> List<T>
toList
(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, Exception> unsafeFunction, Log log) static <T> List<T>
toList
(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, Exception> unsafeFunction, Consumer<Exception> exceptionConsumer) static long[]
toLongArray
(JSONArray jsonArray) static long[]
toLongArray
(JSONArray jsonArray, String jsonObjectKey) toLongList
(JSONArray jsonArray) toLongList
(JSONArray jsonArray, String jsonObjectKey) static Object[]
toObjectArray
(JSONArray jsonArray) static Object[]
toObjectArray
(JSONArray jsonArray, String jsonObjectKey) toObjectList
(JSONArray jsonArray) toObjectList
(JSONArray jsonArray, String jsonObjectKey) toObjectSet
(JSONArray jsonArray) toObjectSet
(JSONArray jsonArray, String jsonObjectKey) static String
static String
toString
(JSONObject jsonObject) static String[]
toStringArray
(JSONArray jsonArray) static String[]
toStringArray
(JSONArray jsonArray, String jsonObjectKey) toStringList
(JSONArray jsonArray) toStringList
(JSONArray jsonArray, String jsonObjectKey) toStringMap
(JSONObject jsonObject) toStringSet
(JSONArray jsonArray) toStringSet
(JSONArray jsonArray, String jsonObjectKey)
-
Constructor Details
-
JSONUtil
public JSONUtil()
-
-
Method Details
-
addToStringCollection
-
addToStringCollection
public static void addToStringCollection(Collection<String> collection, JSONArray jsonArray, String jsonObjectKey) -
concat
-
equals
-
equals
-
getValue
-
getValueAsBoolean
-
getValueAsDouble
-
getValueAsInt
-
getValueAsJSONArray
-
getValueAsJSONObject
-
getValueAsLong
-
getValueAsString
-
hasValue
-
isEmpty
-
isEmpty
-
isJSONArray
-
isJSONObject
-
isValid
Deprecated.As of Cavanaugh (7.4.x), replaced byisJSONObject(String)
-
merge
- Throws:
JSONException
-
put
-
put
-
put
public static JSONObject put(String key, com.liferay.petra.function.UnsafeSupplier<Object, Exception> valueUnsafeSupplier) -
put
-
putAll
-
replace
public static JSONArray replace(JSONArray jsonArray, String jsonObjectKey, JSONObject newJSONObject) -
toArray
public static <T> T[] toArray(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, throws ExceptionException> unsafeFunction, Class<?> clazz) - Throws:
Exception
-
toArray
-
toArray
public static <T> T[] toArray(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, Exception> unsafeFunction, Log log, Class<?> clazz) -
toDoubleArray
-
toDoubleArray
-
toDoubleList
-
toDoubleList
-
toDoubleSet
-
toDoubleSet
-
toFloatArray
-
toFloatArray
-
toFloatList
-
toFloatList
-
toFloatSet
-
toFloatSet
-
toIntegerArray
-
toIntegerArray
-
toIntegerList
-
toIntegerList
-
toIntegerSet
-
toIntegerSet
-
toJSONArray
public static <T> JSONArray toJSONArray(Collection<T> collection, com.liferay.petra.function.UnsafeFunction<T, Object, throws ExceptionException> unsafeFunction) - Throws:
Exception
-
toJSONArray
-
toJSONArray
public static <T> JSONArray toJSONArray(Collection<T> collection, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction, Log log) -
toJSONArray
public static <T> JSONArray toJSONArray(T[] array, com.liferay.petra.function.UnsafeFunction<T, Object, throws ExceptionException> unsafeFunction) - Throws:
Exception
-
toJSONArray
-
toJSONArray
-
toJSONObjectMap
-
toList
public static <T> List<T> toList(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, throws ExceptionException> unsafeFunction) - Throws:
Exception
-
toList
-
toList
public static <T> List<T> toList(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject, T, Exception> unsafeFunction, Log log) -
toLongArray
-
toLongArray
-
toLongList
-
toLongList
-
toLongSet
-
toLongSet
-
toObjectArray
-
toObjectArray
-
toObjectList
-
toObjectList
-
toObjectSet
-
toObjectSet
-
toString
-
toString
-
toStringArray
-
toStringArray
-
toStringList
-
toStringList
-
toStringMap
-
toStringSet
-
toStringSet
-
isJSONObject(String)