@Component
public final class JsonUtilities
extends java.lang.Object
| Constructor and Description |
|---|
JsonUtilities(@NotNull com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
| Modifier and Type | Method and Description |
|---|---|
@NotNull java.util.Iterator<java.lang.String> |
getFieldNames(@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
java.lang.String... childNodes)
Get a string iterator for the field names of the last specified child node in the specified
JsonNode.
|
@NotNull com.fasterxml.jackson.databind.JsonNode |
getJson(@NotNull java.io.File file)
Acquire a
JsonNode from the given json file. |
@NotNull com.fasterxml.jackson.databind.JsonNode |
getJson(@NotNull java.io.InputStream inputStream)
Acquire a
JsonNode from the given json inputstream. |
@NotNull com.fasterxml.jackson.databind.JsonNode |
getJson(@NotNull java.lang.String string)
Acquire a
JsonNode from the given json string. |
@NotNull com.fasterxml.jackson.databind.JsonNode |
getJson(@NotNull java.net.URL url)
Acquire a
JsonNode from the given URL. |
boolean |
getNestedBoolean(@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
java.lang.String... childNodes)
Get the boolean value from the nested child node(s).
|
@NotNull com.fasterxml.jackson.databind.JsonNode |
getNestedElement(@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
java.lang.String... childNodes)
Get a nested element from a JsonNode.
|
@NotNull java.lang.String |
getNestedText(@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
java.lang.String... childNodes)
Get the text from nested child node(s).
|
@NotNull java.lang.String[] |
getNestedTexts(@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull java.lang.String split,
java.lang.String... childNodes)
Get the array of texts from the nested child node(s) comma-separated text.
|
boolean |
nestedTextContains(@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull java.lang.String contains,
java.lang.String... childNodes)
Check whether a child node contains the specified text.
|
boolean |
nestedTextEqualsIgnoreCase(@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull java.lang.String equalsIgnoreCase,
java.lang.String... childNodes)
Check whether the text in specified child node(s) is equal to the specified text,
case-insensitive.
|
boolean |
nestedTextIsEmpty(@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
java.lang.String... childNodes)
Check whether the text in the specified child node(s) is empty.
|
boolean |
nestedTextMatches(@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull java.lang.String matches,
java.lang.String... childNodes)
Check whether the text in specified child node(s) matches the specified text.
|
@Contract(pure=true)
public JsonUtilities(@NotNull
@NotNull com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public boolean nestedTextMatches(@NotNull
@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull
@NotNull java.lang.String matches,
@NotNull
java.lang.String... childNodes)
throws java.lang.NullPointerException
jsonNode - The JsonNode from which to acquire the text.matches - The text to check for a match.childNodes - The nested nodes in the JsonNode to acquire the text from, in order.true if the texts match.java.lang.NullPointerException - if the requested element is not present in the JsonNode.@NotNull
public @NotNull java.lang.String getNestedText(@NotNull
@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull
java.lang.String... childNodes)
throws java.lang.NullPointerException
jsonNode - The JsonNode from which to acquire the text from.childNodes - The child nodes which contain the requested text, in order.java.lang.NullPointerException - if the requested element is not present in the JsonNode.@NotNull
public @NotNull com.fasterxml.jackson.databind.JsonNode getNestedElement(@NotNull
@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull
java.lang.String... childNodes)
throws java.lang.NullPointerException
jsonNode - The JsonNode from which to acquire the nested element.childNodes - The nested elements, in order.java.lang.NullPointerException - if the requested element is not present in the JsonNode.public boolean nestedTextEqualsIgnoreCase(@NotNull
@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull
@NotNull java.lang.String equalsIgnoreCase,
@NotNull
java.lang.String... childNodes)
throws java.lang.NullPointerException
jsonNode - The JsonNode from which to acquire the text.equalsIgnoreCase - The text to check with whether it is equal, case-insensitive.childNodes - The nested nodes in the JsonNode to acquire the text from, in order.true if the texts are equal, case-insensitive.java.lang.NullPointerException - if the requested element is not present in the JsonNode.public boolean nestedTextIsEmpty(@NotNull
@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull
java.lang.String... childNodes)
throws java.lang.NullPointerException
jsonNode - The JsonNode from which to acquire the text.childNodes - The nested nodes in the JsonNode to acquire the text from, in order.true if the text in the requested node is empty.java.lang.NullPointerException - if the requested element is not present in the JsonNode.public boolean getNestedBoolean(@NotNull
@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull
java.lang.String... childNodes)
throws java.lang.NullPointerException,
JsonException
jsonNode - The JsonNode from which to acquire the boolean.childNodes - The nested nodes in the JsonNode to acquire the boolean from, in order.true or false, based on the boolean in the specified child node(s).JsonException - if the specified node(s) contain no boolean or the requested value
is not a parsable boolean value.java.lang.NullPointerException - if the requested element is not present in the JsonNode.@NotNull
public @NotNull java.lang.String[] getNestedTexts(@NotNull
@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull
@NotNull java.lang.String split,
@NotNull
java.lang.String... childNodes)
throws java.lang.NullPointerException
jsonNode - The JsonNode from which to acquire the texts from.split - The character by which to split the text of the last child node into an array
with.childNodes - The nested nodes in the JsonNode to acquire the texts from, in order.java.lang.NullPointerException - if the requested element is not present in the JsonNode.public boolean nestedTextContains(@NotNull
@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull
@NotNull java.lang.String contains,
@NotNull
java.lang.String... childNodes)
throws java.lang.NullPointerException
jsonNode - The JsonNode from which to acquire the text for checks.contains - The text to check with whether the node contains it.childNodes - The child node(s) from which to acquire the text for contain-checks from, in
order.true if the child node contains the specified text.java.lang.NullPointerException - if the requested element is not present in the JsonNode.@NotNull
public @NotNull java.util.Iterator<java.lang.String> getFieldNames(@NotNull
@NotNull com.fasterxml.jackson.databind.JsonNode jsonNode,
@NotNull
java.lang.String... childNodes)
throws java.lang.NullPointerException
jsonNode - The JsonNode from which to get the string iterator.childNodes - The nested nodes from which to get the iterator, in order.java.lang.NullPointerException - if any of the specified child nodes can not be found in the passed
JsonNode.@NotNull
public @NotNull com.fasterxml.jackson.databind.JsonNode getJson(@NotNull
@NotNull java.io.InputStream inputStream)
throws java.io.IOException
JsonNode from the given json inputstream.inputStream - The inputstream to read.java.io.IOException - when the file could not be parsed/read into a JsonNode.@NotNull
public @NotNull com.fasterxml.jackson.databind.JsonNode getJson(@NotNull
@NotNull java.lang.String string)
throws java.io.IOException
JsonNode from the given json string.string - The string to read.java.io.IOException - when the file could not be parsed/read into a JsonNode.@NotNull
public @NotNull com.fasterxml.jackson.databind.JsonNode getJson(@NotNull
@NotNull java.io.File file)
throws java.io.IOException
JsonNode from the given json file.file - The file to read.java.io.IOException - when the file could not be parsed/read into a JsonNode.@NotNull
public @NotNull com.fasterxml.jackson.databind.JsonNode getJson(@NotNull
@NotNull java.net.URL url)
throws java.io.IOException
JsonNode from the given URL.url - URL to the data which contains your JSON.java.io.IOException - when the file could not be parsed/read into a JsonNode.