JsonUtilities

class JsonUtilities(val objectMapper: ObjectMapper = ObjectMapper() .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) .enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature()))

JSON-based utility methods for acquiring and working with JSON from files and objects.

Author

Griefed

Parameters

objectMapper

Used for JSON-parsing.

Constructors

Link copied to clipboard
constructor(objectMapper: ObjectMapper = ObjectMapper() .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) .enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature()))

Properties

Link copied to clipboard
val objectMapper: ObjectMapper

Functions

Link copied to clipboard
fun getFieldNames(jsonNode: JsonNode, vararg childNodes: String): MutableIterator<String>

Get a string iterator for the field names of the last specified child node in the specified JsonNode.

Link copied to clipboard
fun getJson(file: File): JsonNode

Acquire a JsonNode from the given json file.

fun getJson(inputStream: InputStream): <Error class: unknown class>

Acquire a JsonNode from the given json input-stream.

fun getJson(url: URL): JsonNode

Acquire a JsonNode from the given URL.

fun getJson(string: String): JsonNode

Acquire a JsonNode from the given json string.

Link copied to clipboard
fun getNestedBoolean(jsonNode: JsonNode, vararg childNodes: String): Boolean

Get the boolean value from the nested child node(s).

Link copied to clipboard
fun getNestedElement(jsonNode: JsonNode, vararg childNodes: String): JsonNode

Get a nested element from a JsonNode.

Link copied to clipboard
fun getNestedText(jsonNode: JsonNode, vararg childNodes: String): String

Get the text from nested child node(s).

Link copied to clipboard
fun getNestedTexts(jsonNode: JsonNode, split: String, vararg childNodes: String): <Error class: unknown class>

Get the array of texts from the nested child node(s) comma-separated text.

Link copied to clipboard
fun nestedTextContains(jsonNode: JsonNode, contains: String, vararg childNodes: String): <Error class: unknown class>

Check whether a child node contains the specified text.

Link copied to clipboard
fun nestedTextEqualsIgnoreCase(jsonNode: JsonNode, equalsIgnoreCase: String, vararg childNodes: String): Boolean

Check whether the text in specified child node(s) is equal to the specified text, case-insensitive.

Link copied to clipboard
fun nestedTextIsEmpty(jsonNode: JsonNode, vararg childNodes: String): <Error class: unknown class>

Check whether the text in the specified child node(s) is empty.

Link copied to clipboard
fun nestedTextMatches(jsonNode: JsonNode, matches: Regex, vararg childNodes: String): <Error class: unknown class>

Check whether the text in specified child node(s) matches the specified text.