toObjectNode

fun String.toObjectNode(): ObjectNode

Parses this JSON string into an ObjectNode.

Convenience method that parses the string and casts to ObjectNode.

Receiver

The JSON string to parse.

Return

The parsed ObjectNode.

Throws

JsonProcessingException

if parsing fails.

if the parsed JSON is not an object.

Example:

val json = """{"name":"John","age":30}"""
val node = json.toObjectNode()
val name = node["name"].asText() // "John"