JsonUtil
The JsonUtil
class provides utility methods for working with JSON data. It includes methods for converting objects to JSON, parsing JSON strings, and manipulating JSON data.
Methods
toJson(object: any): JsonNode
toJson(object: any): JsonNode
Converts a JavaScript object to a JSON representation and returns a JsonNode
object.
parse(jsonStr: String): JsonNode
parse(jsonStr: String): JsonNode
Parses a JSON string and returns a JsonNode
object representing the parsed JSON data.
stringify(jsonNode: JsonNode): String
stringify(jsonNode: JsonNode): String
Converts a JsonNode
object back to a JSON string.
prettyPrint(jsonNode: JsonNode): String
prettyPrint(jsonNode: JsonNode): String
Formats and pretty-prints a JsonNode
object as a JSON string with proper indentation and line breaks.
readPath(jsonNode: String, path: String): any
readPath(jsonNode: String, path: String): any
Reads a specific value from a JSON object using a JSON path and returns it.
createObjectNode(): ObjectNode
createObjectNode(): ObjectNode
Create an empty Json Object to be set with values.
Examples
Example: JSON Read Using JSON Path
Description: This script reads a JSON property value using JSON path from a JSON string.
Use Case: Useful for extracting specific data from structured JSON objects.
Last updated