public final class JsonUtils extends Object
Modifier and Type | Method and Description |
---|---|
static ArrayNode |
appendArray(ArrayNode array,
ArrayNode otherArray)
Returns a new ArrayNode that is the same as the given array but adds all elements of the other array.
|
static ObjectNode |
appendObject(ObjectNode object,
ObjectNode otherObject)
Returns a new ObjectNode that is the same as the given object but adds all fields of the other object.
|
static Optional<ArrayNode> |
asArray(JsonNode node)
Returns the given JSON node if it is an array node.
|
static Optional<ObjectNode> |
asObject(JsonNode node)
Returns the given JSON node if it is an object node.
|
static ArrayNode |
createArrayNode()
Returns a new empty ArrayNode.
|
static ObjectNode |
createObjectNode()
Returns a new empty ObjectNode.
|
static ArrayNode |
expectArray(JsonNode node)
Returns the given JSON node as an array node.
|
static ObjectNode |
expectObject(JsonNode node)
Returns the given JSON node as an object node.
|
static boolean |
isInteger(String value)
Returns true if the given string represents an integer
|
static boolean |
isMissing(JsonNode node)
Returns true if the given JSON node is null or missing.
|
static ObjectMapper |
mapper()
Returns a JSON ObjectMapper.
|
static ArrayNode |
newArray(JsonNode element)
Returns a new ArrayNode containing given element
|
static ObjectNode |
newObject(String field,
JsonNode value)
Returns a new ObjectNode containing given field value.
|
static List<String> |
pathOf(JsonPointer pointer)
Returns the path represented by the given JSON pointer.
|
static JsonPointer |
pointer(Iterable<String> path)
Returns a JSON pointer for the given path
|
static JsonPointer |
pointer(String... path)
Returns a JSON pointer for the given path
|
static JsonNode |
readJson(Reader content)
Returns the JSON value represented by content from the given Reader.
|
static JsonNode |
readJson(String content)
Returns the JSON value represented by the given content.
|
static String |
tailOf(JsonPointer pointer)
Returns the final segment of the given JSON pointer.
|
public static ObjectNode expectObject(JsonNode node)
public static Optional<ObjectNode> asObject(JsonNode node)
Optional.empty()
.public static ObjectNode newObject(String field, JsonNode value)
public static ObjectNode appendObject(ObjectNode object, ObjectNode otherObject)
public static ArrayNode expectArray(JsonNode node)
public static Optional<ArrayNode> asArray(JsonNode node)
Optional.empty()
.public static ArrayNode newArray(JsonNode element)
public static ArrayNode appendArray(ArrayNode array, ArrayNode otherArray)
public static boolean isMissing(JsonNode node)
public static boolean isInteger(String value)
public static JsonPointer pointer(String... path)
public static JsonPointer pointer(Iterable<String> path)
public static String tailOf(JsonPointer pointer)
public static List<String> pathOf(JsonPointer pointer)
public static ObjectNode createObjectNode()
public static ArrayNode createArrayNode()
public static ObjectMapper mapper()
public static JsonNode readJson(String content) throws IOException
IOException
public static JsonNode readJson(Reader content) throws IOException
IOException
Copyright © 2024 The Cornutum Project. All rights reserved.