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 voidaddToStringCollection(Collection<String> collection, JSONArray jsonArray) static voidaddToStringCollection(Collection<String> collection, JSONArray jsonArray, String jsonObjectKey) static JSONArraystatic booleanstatic booleanequals(JSONObject jsonObject1, JSONObject jsonObject2) static Objectstatic booleangetValueAsBoolean(Object object, String... paths) static doublegetValueAsDouble(Object object, String... paths) static intgetValueAsInt(Object object, String... paths) static JSONArraygetValueAsJSONArray(Object object, String... paths) static JSONObjectgetValueAsJSONObject(Object object, String... paths) static longgetValueAsLong(Object object, String... paths) static StringgetValueAsString(Object object, String... paths) static booleanstatic booleanstatic booleanisEmpty(JSONObject jsonObject) static booleanisJSONArray(String json) static booleanisJSONObject(String json) static booleanDeprecated.static JSONObjectmerge(JSONObject jsonObject1, JSONObject jsonObject2) static JSONArraystatic JSONArraystatic JSONObjectstatic JSONObjectstatic JSONArraystatic JSONArrayreplace(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> JSONArraytoJSONArray(Collection<T> collection, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction) static <T> JSONArraytoJSONArray(Collection<T> collection, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction, Log log) static <T> JSONArraytoJSONArray(Collection<T> collection, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction, Consumer<Exception> exceptionConsumer) static <T> JSONArraytoJSONArray(T[] array, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction) static <T> JSONArraytoJSONArray(T[] array, com.liferay.petra.function.UnsafeFunction<T, Object, Exception> unsafeFunction, Log log) static <T> JSONArraytoJSONArray(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 Stringstatic StringtoString(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)