public final class JSONUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
JSONUtil.JSONPair
Simply stores a key and a value, used internally by many methods below.
|
Modifier and Type | Method and Description |
---|---|
static @NotNull Map<String,Object> |
appendObjectData(@NotNull Map parent,
JSONUtil.JSONPair... data)
This appends multiple key/value Obj pairs into a JSON Object
|
static @NotNull Map<String,Object> |
createObject(JSONUtil.JSONPair... data)
Creates a new JSON object from multiple JSONPair key/value pairs
|
static @NotNull JSONUtil.JSONPair |
pair(long key,
@Nullable Object obj) |
static @NotNull JSONUtil.JSONPair |
pair(@NotNull String key,
@Nullable Object obj)
Creates a key/value "JSONPair" object
|
static @NotNull List |
toArray(Object... data)
This builds a JSON array from a set of data
|
static <E> @NotNull List |
toArrayMapper(E[] collection,
@NotNull Function<E,Object> mapper)
These help build a single JSON array using a mapper function
|
static <E> @NotNull List |
toArrayMapper(@NotNull Iterable<E> collection,
@NotNull Function<E,Object> mapper) |
static <E> @NotNull Map |
toObjectMapper(E[] collection,
@NotNull Function<E,JSONUtil.JSONPair> mapper)
These help build a single JSON Object from a collection, using a mapper function
|
static <E> @NotNull Map |
toObjectMapper(@NotNull Iterable<E> collection,
@NotNull Function<E,JSONUtil.JSONPair> mapper) |
@NotNull public static @NotNull JSONUtil.JSONPair pair(@NotNull @NotNull String key, @Nullable @Nullable Object obj)
key
- Key to useobj
- Value to use@NotNull public static @NotNull JSONUtil.JSONPair pair(long key, @Nullable @Nullable Object obj)
@NotNull public static @NotNull Map<String,Object> createObject(@NotNull JSONUtil.JSONPair... data)
data
- JSONPairs@NotNull public static @NotNull Map<String,Object> appendObjectData(@NotNull @NotNull Map parent, @NotNull JSONUtil.JSONPair... data)
parent
- Map to be appended todata
- Data to append@NotNull public static @NotNull List toArray(@NotNull Object... data)
data
- Data to build JSON array from@NotNull public static <E> @NotNull List toArrayMapper(@NotNull E[] collection, @NotNull @NotNull Function<E,Object> mapper)
E
- Element Typecollection
- Collection to apply tomapper
- Mapper to apply@NotNull public static <E> @NotNull List toArrayMapper(@NotNull @NotNull Iterable<E> collection, @NotNull @NotNull Function<E,Object> mapper)
@NotNull public static <E> @NotNull Map toObjectMapper(@NotNull E[] collection, @NotNull @NotNull Function<E,JSONUtil.JSONPair> mapper)
E
- Element Typecollection
- Collection to apply tomapper
- Mapper to applyCopyright © 2021. All rights reserved.