Package co.aikar.util

# Class JSONUtil

java.lang.Object
co.aikar.util.JSONUtil

public final class JSONUtil extends Object
Provides Utility methods that assist with generating JSON Objects

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`JSONUtil.JSONPair`
Simply stores a key and a value, used internally by many methods below.

## Method Summary

Modifier and Type
Method
Description
`static @NotNull Map<String,Object>`
`appendObjectData(@NotNull Map parent, @NotNull JSONUtil.JSONPair... data)`
This appends multiple key/value Obj pairs into a JSON Object
`static @NotNull Map<String,Object>`
`createObject(@NotNull 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(@NotNull Object... data)`
This builds a JSON array from a set of data
`static <E> @NotNull List`
`toArrayMapper(@NotNull 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(@NotNull 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)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### pair

@NotNull public static @NotNull JSONUtil.JSONPair pair(@NotNull @NotNull String key, @Nullable @Nullable Object obj)
Creates a key/value "JSONPair" object

Parameters:
  `key` - Key to use
  `obj` - Value to use
Returns:
  JSONPair

### pair

@NotNull public static @NotNull JSONUtil.JSONPair pair(long key, @Nullable @Nullable Object obj)

### createObject

@NotNull public static @NotNull Map<String,Object> createObject(@NotNull @NotNull JSONUtil.JSONPair... data)
Creates a new JSON object from multiple JSONPair key/value pairs

Parameters:
  `data` - JSONPairs
Returns:
  Map

### appendObjectData

@NotNull public static @NotNull Map<String,Object> appendObjectData(@NotNull @NotNull Map parent, @NotNull @NotNull JSONUtil.JSONPair... data)
This appends multiple key/value Obj pairs into a JSON Object

Parameters:
  `parent` - Map to be appended to
  `data` - Data to append
Returns:
  Map

### toArray

@NotNull public static @NotNull List toArray(@NotNull @NotNull Object... data)
This builds a JSON array from a set of data

Parameters:
  `data` - Data to build JSON array from
Returns:
  List

### toArrayMapper

@NotNull public static <E> @NotNull List toArrayMapper(@NotNull @NotNull E[] collection, @NotNull @NotNull Function<E,Object> mapper)
These help build a single JSON array using a mapper function

Type Parameters:
  `E` - Element Type
Parameters:
  `collection` - Collection to apply to
  `mapper` - Mapper to apply
Returns:
  List

### toArrayMapper

@NotNull public static <E> @NotNull List toArrayMapper(@NotNull @NotNull Iterable<E> collection, @NotNull @NotNull Function<E,Object> mapper)

### toObjectMapper

@NotNull public static <E> @NotNull Map toObjectMapper(@NotNull @NotNull E[] collection, @NotNull @NotNull Function<E,JSONUtil.JSONPair> mapper)
These help build a single JSON Object from a collection, using a mapper function

Type Parameters:
  `E` - Element Type
Parameters:
  `collection` - Collection to apply to
  `mapper` - Mapper to apply
Returns:
  Map

### toObjectMapper

@NotNull public static <E> @NotNull Map toObjectMapper(@NotNull @NotNull Iterable<E> collection, @NotNull @NotNull Function<E,JSONUtil.JSONPair> mapper)