public class JSONUtil
extends Object
Constructor and Description |
---|
JSONUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
addToStringCollection(Collection<String> collection,
JSONArray jsonArray) |
static void |
addToStringCollection(Collection<String> collection,
JSONArray jsonArray,
String jsonObjectKey) |
static JSONArray |
concat(JSONArray... jsonArrays) |
static Collector<Object,JSONArray,JSONArray> |
createCollector() |
static boolean |
equals(JSONArray jsonArray1,
JSONArray jsonArray2) |
static boolean |
equals(JSONObject jsonObject1,
JSONObject jsonObject2) |
static Object |
getValue(Object object,
String... paths) |
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 |
hasValue(JSONArray jsonArray,
Object value) |
static boolean |
isValid(String json) |
static JSONObject |
merge(JSONObject jsonObject1,
JSONObject jsonObject2) |
static JSONArray |
put(Object... values)
Deprecated.
As of Mueller (7.2.x), replaced by
putAll(Object...) |
static JSONArray |
put(Object value) |
static JSONObject |
put(String key,
Object value) |
static JSONArray |
putAll(Object... values) |
static JSONArray |
replace(JSONArray jsonArray,
String jsonObjectKey,
JSONObject newJSONObject) |
static <T> T[] |
toArray(JSONArray jsonArray,
com.liferay.petra.function.UnsafeFunction<JSONObject,T,Exception> unsafeFunction,
Class<?> clazz) |
static <T> JSONArray |
toJSONArray(List<T> list,
com.liferay.petra.function.UnsafeFunction<T,Object,Exception> unsafeFunction) |
static <T> JSONArray |
toJSONArray(Set<T> set,
com.liferay.petra.function.UnsafeFunction<T,Object,Exception> unsafeFunction) |
static <T> JSONArray |
toJSONArray(T[] array,
com.liferay.petra.function.UnsafeFunction<T,Object,Exception> unsafeFunction) |
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 long[] |
toLongArray(JSONArray jsonArray) |
static long[] |
toLongArray(JSONArray jsonArray,
String jsonObjectKey) |
static List<Long> |
toLongList(JSONArray jsonArray) |
static List<Long> |
toLongList(JSONArray jsonArray,
String jsonObjectKey) |
static Set<Long> |
toLongSet(JSONArray jsonArray) |
static Set<Long> |
toLongSet(JSONArray jsonArray,
String jsonObjectKey) |
static Object[] |
toObjectArray(JSONArray jsonArray) |
static Object[] |
toObjectArray(JSONArray jsonArray,
String jsonObjectKey) |
static List<Object> |
toObjectList(JSONArray jsonArray) |
static List<Object> |
toObjectList(JSONArray jsonArray,
String jsonObjectKey) |
static Set<Object> |
toObjectSet(JSONArray jsonArray) |
static Set<Object> |
toObjectSet(JSONArray jsonArray,
String jsonObjectKey) |
static String |
toString(JSONArray jsonArray) |
static String |
toString(JSONObject jsonObject) |
static String[] |
toStringArray(JSONArray jsonArray) |
static String[] |
toStringArray(JSONArray jsonArray,
String jsonObjectKey) |
static List<String> |
toStringList(JSONArray jsonArray) |
static List<String> |
toStringList(JSONArray jsonArray,
String jsonObjectKey) |
static Set<String> |
toStringSet(JSONArray jsonArray) |
static Set<String> |
toStringSet(JSONArray jsonArray,
String jsonObjectKey) |
public static void addToStringCollection(Collection<String> collection, JSONArray jsonArray)
public static void addToStringCollection(Collection<String> collection, JSONArray jsonArray, String jsonObjectKey)
public static boolean equals(JSONObject jsonObject1, JSONObject jsonObject2)
public static Object getValue(Object object, String... paths)
public static boolean getValueAsBoolean(Object object, String... paths)
public static double getValueAsDouble(Object object, String... paths)
public static int getValueAsInt(Object object, String... paths)
public static JSONArray getValueAsJSONArray(Object object, String... paths)
public static JSONObject getValueAsJSONObject(Object object, String... paths)
public static long getValueAsLong(Object object, String... paths)
public static String getValueAsString(Object object, String... paths)
public static boolean hasValue(JSONArray jsonArray, Object value)
public static boolean isValid(String json)
public static JSONObject merge(JSONObject jsonObject1, JSONObject jsonObject2) throws JSONException
JSONException
public static JSONArray put(Object value)
@Deprecated public static JSONArray put(Object... values)
putAll(Object...)
public static JSONObject put(String key, Object value)
public static JSONArray putAll(Object... values)
public static JSONArray replace(JSONArray jsonArray, String jsonObjectKey, JSONObject newJSONObject)
public static <T> T[] toArray(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject,T,Exception> unsafeFunction, Class<?> clazz) throws Exception
Exception
public static <T> JSONArray toJSONArray(List<T> list, com.liferay.petra.function.UnsafeFunction<T,Object,Exception> unsafeFunction) throws Exception
Exception
public static <T> JSONArray toJSONArray(Set<T> set, com.liferay.petra.function.UnsafeFunction<T,Object,Exception> unsafeFunction) throws Exception
Exception
public static <T> JSONArray toJSONArray(T[] array, com.liferay.petra.function.UnsafeFunction<T,Object,Exception> unsafeFunction) throws Exception
Exception
public static Map<String,JSONObject> toJSONObjectMap(JSONArray jsonArray, String jsonObjectKey)
public static <T> List<T> toList(JSONArray jsonArray, com.liferay.petra.function.UnsafeFunction<JSONObject,T,Exception> unsafeFunction) throws Exception
Exception
public static long[] toLongArray(JSONArray jsonArray)
public static long[] toLongArray(JSONArray jsonArray, String jsonObjectKey)
public static List<Long> toLongList(JSONArray jsonArray)
public static List<Long> toLongList(JSONArray jsonArray, String jsonObjectKey)
public static Set<Long> toLongSet(JSONArray jsonArray)
public static Set<Long> toLongSet(JSONArray jsonArray, String jsonObjectKey)
public static Object[] toObjectArray(JSONArray jsonArray)
public static Object[] toObjectArray(JSONArray jsonArray, String jsonObjectKey)
public static List<Object> toObjectList(JSONArray jsonArray)
public static List<Object> toObjectList(JSONArray jsonArray, String jsonObjectKey)
public static Set<Object> toObjectSet(JSONArray jsonArray)
public static Set<Object> toObjectSet(JSONArray jsonArray, String jsonObjectKey)
public static String toString(JSONArray jsonArray)
public static String toString(JSONObject jsonObject)
public static String[] toStringArray(JSONArray jsonArray)
public static String[] toStringArray(JSONArray jsonArray, String jsonObjectKey)
public static List<String> toStringList(JSONArray jsonArray)
public static List<String> toStringList(JSONArray jsonArray, String jsonObjectKey)
public static Set<String> toStringSet(JSONArray jsonArray)
public static Set<String> toStringSet(JSONArray jsonArray, String jsonObjectKey)