toJsonNode
Converts this object to a JsonNode representation.
Uses the pre-configured JsonSerializer to convert the object to a tree structure.
Receiver
The object to convert. Can be any type.
Return
The JsonNode representation of the object.
Parameters
T
The specific type of JsonNode to return (e.g., ObjectNode, ArrayNode).
Throws
JsonProcessingException
if conversion fails.
Example:
val user = mapOf("name" to "John", "age" to 30)
val node = user.toJsonNode<ObjectNode>()
val name = node["name"].asText() // "John"Content copied to clipboard
Parses this JSON string into a JsonNode representation.
Uses the pre-configured JsonSerializer to parse the JSON string.
Receiver
The JSON string to parse.
Return
The parsed JsonNode.
Parameters
T
The specific type of JsonNode to return (e.g., ObjectNode, ArrayNode).
Throws
JsonProcessingException
if parsing fails.
Example:
val json = """{"name":"John","age":30}"""
val node = json.toJsonNode<ObjectNode>()
val name = node["name"].asText() // "John"Content copied to clipboard