public final class JsonUtils extends Object
elemental.json
.Modifier and Type | Method and Description |
---|---|
static Collector<elemental.json.JsonValue,elemental.json.JsonArray,elemental.json.JsonArray> |
asArray()
Creates a collector that collects values into a JSON array.
|
static elemental.json.JsonArray |
createArray(elemental.json.JsonValue... values)
Creates a new JSON array with the given values.
|
static <T> elemental.json.JsonObject |
createObject(Map<String,T> map,
Function<T,elemental.json.JsonValue> itemToJson)
Converts the given map into a JSON object by converting each map value to
a JSON value.
|
static boolean |
jsonEquals(elemental.json.JsonValue a,
elemental.json.JsonValue b)
Compares two json values for deep equality.
|
static DoubleStream |
numberStream(elemental.json.JsonArray array)
Creates a double stream from a JSON array of numbers.
|
static Stream<elemental.json.JsonObject> |
objectStream(elemental.json.JsonArray array)
Creates a stream from a JSON array of objects.
|
static <T extends elemental.json.JsonValue> |
stream(elemental.json.JsonArray array)
Creates a stream from a JSON array.
|
public static boolean jsonEquals(elemental.json.JsonValue a, elemental.json.JsonValue b)
This is a helper for overcoming the fact that JsonValue
doesn't
override Object.equals(Object)
and
JsonValue.jsEquals(JsonValue)
is defined to use JavaScript
semantics where arrays and objects are equals only based on identity.
a
- the first json value to check, may not be nullb
- the second json value to check, may not be nulltrue
if both json values are the same;
false
otherwisepublic static <T extends elemental.json.JsonValue> Stream<T> stream(elemental.json.JsonArray array)
T
- the stream typearray
- the JSON array to create a stream frompublic static Stream<elemental.json.JsonObject> objectStream(elemental.json.JsonArray array)
array
- the JSON array to create a stream frompublic static DoubleStream numberStream(elemental.json.JsonArray array)
array
- the JSON array to create a stream frompublic static Collector<elemental.json.JsonValue,elemental.json.JsonArray,elemental.json.JsonArray> asArray()
public static elemental.json.JsonArray createArray(elemental.json.JsonValue... values)
values
- the values that should be in the created arraypublic static <T> elemental.json.JsonObject createObject(Map<String,T> map, Function<T,elemental.json.JsonValue> itemToJson)
T
- the type of the map valuesmap
- the map to convert into a JSON objectitemToJson
- callback for converting map values to JSONCopyright © 2020. All rights reserved.