Class JsonOps
java.lang.Object
com.github.darksoulq.abyssallib.common.serialization.DynamicOps<com.fasterxml.jackson.databind.JsonNode>
com.github.darksoulq.abyssallib.common.serialization.ops.JsonOps
A
DynamicOps implementation backed by Jackson's JsonNode tree model.
This implementation allows codecs to serialize and deserialize structured data into standard JSON representations using Jackson's immutable tree API.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.JsonNodecopy(com.fasterxml.jackson.databind.JsonNode input) Creates a deep copy of the JSON node.com.fasterxml.jackson.databind.JsonNodecreateBoolean(boolean value) Creates a JSON boolean node.com.fasterxml.jackson.databind.JsonNodecreateByte(byte value) Creates a JSON numeric node representing a byte.com.fasterxml.jackson.databind.JsonNodecreateDouble(double value) Creates a JSON numeric node representing a double.com.fasterxml.jackson.databind.JsonNodecreateFloat(float value) Creates a JSON numeric node representing a float.com.fasterxml.jackson.databind.JsonNodecreateInt(int value) Creates a JSON numeric node representing an int.com.fasterxml.jackson.databind.JsonNodecreateList(List<com.fasterxml.jackson.databind.JsonNode> elements) Creates a JSON array node from a list of elements.com.fasterxml.jackson.databind.JsonNodecreateLong(long value) Creates a JSON numeric node representing a long.com.fasterxml.jackson.databind.JsonNodecreateMap(Map<com.fasterxml.jackson.databind.JsonNode, com.fasterxml.jackson.databind.JsonNode> map) Creates a JSON object node from a map of key-value pairs.com.fasterxml.jackson.databind.JsonNodecreateShort(short value) Creates a JSON numeric node representing a short.com.fasterxml.jackson.databind.JsonNodecreateString(String value) Creates a JSON string node.com.fasterxml.jackson.databind.JsonNodeempty()Returns the representation of an empty JSON value.getBooleanValue(com.fasterxml.jackson.databind.JsonNode input) Extracts a boolean value from a JSON node if it is boolean.getDoubleValue(com.fasterxml.jackson.databind.JsonNode input) Extracts a double value from a JSON node if it is numeric.getFloatValue(com.fasterxml.jackson.databind.JsonNode input) Extracts a float value from a JSON node if it is numeric.getIntValue(com.fasterxml.jackson.databind.JsonNode input) Extracts an integer value from a JSON node if it is numeric.getKeys(com.fasterxml.jackson.databind.JsonNode input) Returns the keys of a JSON object node.getList(com.fasterxml.jackson.databind.JsonNode input) Converts a JSON array node into a list of JSON nodes.getLongValue(com.fasterxml.jackson.databind.JsonNode input) Extracts a long value from a JSON node if it is numeric.getMap(com.fasterxml.jackson.databind.JsonNode input) Converts a JSON object node into a map of JSON nodes.getNumberValue(com.fasterxml.jackson.databind.JsonNode input) Extracts a numeric value from a JSON node if it is numeric.getStringValue(com.fasterxml.jackson.databind.JsonNode input) Extracts a string value from a JSON node if it is textual.size(com.fasterxml.jackson.databind.JsonNode input) Returns the number of elements in a JSON container node.Methods inherited from class DynamicOps
compressMaps, convertTo, edit, edit, emptyList, emptyMap, exists, exists, mergeToList, mergeToMap, query, query, remove, remove, set, set
-
Field Details
-
INSTANCE
Singleton instance ofJsonOps. -
mapper
public final com.fasterxml.jackson.databind.ObjectMapper mapperUnderlying Jackson object mapper used for JSON operations.
-
-
Method Details
-
createString
Creates a JSON string node.- Specified by:
createStringin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
value- the string value- Returns:
- a
TextNodecontaining the value
-
createByte
public com.fasterxml.jackson.databind.JsonNode createByte(byte value) Creates a JSON numeric node representing a byte.- Specified by:
createBytein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
value- the byte value- Returns:
- an
IntNode
-
createShort
public com.fasterxml.jackson.databind.JsonNode createShort(short value) Creates a JSON numeric node representing a short.- Specified by:
createShortin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
value- the short value- Returns:
- an
IntNode
-
createInt
public com.fasterxml.jackson.databind.JsonNode createInt(int value) Creates a JSON numeric node representing an int.- Specified by:
createIntin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
value- the int value- Returns:
- an
IntNode
-
createLong
public com.fasterxml.jackson.databind.JsonNode createLong(long value) Creates a JSON numeric node representing a long.- Specified by:
createLongin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
value- the long value- Returns:
- a
LongNode
-
createFloat
public com.fasterxml.jackson.databind.JsonNode createFloat(float value) Creates a JSON numeric node representing a float.- Specified by:
createFloatin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
value- the float value- Returns:
- a
FloatNode
-
createDouble
public com.fasterxml.jackson.databind.JsonNode createDouble(double value) Creates a JSON numeric node representing a double.- Specified by:
createDoublein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
value- the double value- Returns:
- a
DoubleNode
-
createBoolean
public com.fasterxml.jackson.databind.JsonNode createBoolean(boolean value) Creates a JSON boolean node.- Specified by:
createBooleanin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
value- the boolean value- Returns:
- a
BooleanNode
-
createList
public com.fasterxml.jackson.databind.JsonNode createList(List<com.fasterxml.jackson.databind.JsonNode> elements) Creates a JSON array node from a list of elements.- Specified by:
createListin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
elements- the list of JSON nodes- Returns:
- an
ArrayNode
-
createMap
public com.fasterxml.jackson.databind.JsonNode createMap(Map<com.fasterxml.jackson.databind.JsonNode, com.fasterxml.jackson.databind.JsonNode> map) Creates a JSON object node from a map of key-value pairs.Keys are converted to strings using
JsonNode.asText().- Specified by:
createMapin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
map- the map of JSON nodes- Returns:
- an
ObjectNode
-
getStringValue
Extracts a string value from a JSON node if it is textual.- Specified by:
getStringValuein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the string value if present
-
getNumberValue
Extracts a numeric value from a JSON node if it is numeric.- Specified by:
getNumberValuein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the number value if present
-
getIntValue
Extracts an integer value from a JSON node if it is numeric.- Specified by:
getIntValuein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the integer value if present
-
getLongValue
Extracts a long value from a JSON node if it is numeric.- Specified by:
getLongValuein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the long value if present
-
getFloatValue
Extracts a float value from a JSON node if it is numeric.- Specified by:
getFloatValuein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the float value if present
-
getDoubleValue
Extracts a double value from a JSON node if it is numeric.- Specified by:
getDoubleValuein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the double value if present
-
getBooleanValue
Extracts a boolean value from a JSON node if it is boolean.- Specified by:
getBooleanValuein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the boolean value if present
-
getList
public Optional<List<com.fasterxml.jackson.databind.JsonNode>> getList(com.fasterxml.jackson.databind.JsonNode input) Converts a JSON array node into a list of JSON nodes.- Specified by:
getListin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the list of elements if the node is an array
-
getMap
public Optional<Map<com.fasterxml.jackson.databind.JsonNode, com.fasterxml.jackson.databind.JsonNode>> getMap(com.fasterxml.jackson.databind.JsonNode input) Converts a JSON object node into a map of JSON nodes.- Specified by:
getMapin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the map of entries if the node is an object
-
getKeys
Returns the keys of a JSON object node.- Specified by:
getKeysin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- an iterable of field names if the node is an object
-
size
Returns the number of elements in a JSON container node.- Specified by:
sizein classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- the size if the node is a container
-
copy
public com.fasterxml.jackson.databind.JsonNode copy(com.fasterxml.jackson.databind.JsonNode input) Creates a deep copy of the JSON node.- Specified by:
copyin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Parameters:
input- the JSON node- Returns:
- a deep-copied node
-
empty
public com.fasterxml.jackson.databind.JsonNode empty()Returns the representation of an empty JSON value.- Specified by:
emptyin classDynamicOps<com.fasterxml.jackson.databind.JsonNode>- Returns:
NullNode.instance
-