Package dev.harrel.jsonschema
Interface JsonNode
- All Known Implementing Classes:
GsonNode,JacksonNode,JakartaJsonNode,JettisonNode,JsonSmartNode,KotlinxJsonNode,OrgJsonNode,SnakeYamlNode
public interface JsonNode
JsonNode interface is the main abstraction for provider-agnostic JSON node.
Implementations are required to implement Object.equals(Object) and Object.hashCode().
Equality check must follow JSON equality rules, e.g. JSON properties order is not relevant.-
Method Summary
Modifier and TypeMethodDescriptionasArray()Returns JSON node as an array.booleanReturns JSON node as a boolean.Returns JSON node as an integer.asNumber()Returns JSON node as a number.asObject()Returns JSON node as an object.asString()Returns JSON node as a string.static StringencodeJsonPointer(String pointer) Encodes all illegal characters in JSON pointer segmentJSON pointer getter.Node type getterdefault booleanisArray()Checks if JSON node is an array.default booleanChecks if JSON node is a boolean.default booleanChecks if JSON node is an integer.default booleanisNull()Checks if JSON node is null.default booleanisNumber()Checks if JSON node is a number.default booleanisObject()Checks if JSON node is an object.default booleanisString()Checks if JSON node is a string.default StringConverts JSON node to printable string.
-
Method Details
-
encodeJsonPointer
Encodes all illegal characters in JSON pointer segment- Parameters:
pointer- JSON pointer segment- Returns:
- encoded JSON pointer segment
-
getJsonPointer
String getJsonPointer()JSON pointer getter.- Returns:
- JSON pointer
-
getNodeType
SimpleType getNodeType()Node type getter- Returns:
- type of node
-
isNull
default boolean isNull()Checks if JSON node is null. -
isBoolean
default boolean isBoolean()Checks if JSON node is a boolean. -
isString
default boolean isString()Checks if JSON node is a string. -
isInteger
default boolean isInteger()Checks if JSON node is an integer. -
isNumber
default boolean isNumber()Checks if JSON node is a number. -
isArray
default boolean isArray()Checks if JSON node is an array. -
isObject
default boolean isObject()Checks if JSON node is an object. -
asBoolean
boolean asBoolean()Returns JSON node as a boolean. If JSON node is not of a boolean type, then the behaviour is undefined. -
asString
String asString()Returns JSON node as a string. If JSON node is not of a string type, then the behaviour is undefined. -
asInteger
BigInteger asInteger()Returns JSON node as an integer. If JSON node is not of an integer type, then the behaviour is undefined. -
asNumber
BigDecimal asNumber()Returns JSON node as a number. If JSON node is not of a number type, then the behaviour is undefined. -
asArray
Returns JSON node as an array. If JSON node is not of an array type, then the behaviour is undefined. -
asObject
Returns JSON node as an object. If JSON node is not of an object type, then the behaviour is undefined. -
toPrintableString
Converts JSON node to printable string. This method is only used for validation messages construction.
-