The JSON utilities package enables you to extract and parse information from JSON data sources. The package contains actions for manipulating the JSON data, such as adding or updating values within a JSON string, parsing JSON strings into objects using node path, and converting JSON strings to dictionaries and vice versa.
Overview
JavaScript Object Notation (JSON) is a lightweight, easy-to-understand, extensible format for storing, transporting, and retrieving data. JSON represents the data in key-value pairs format and supports efficient data interchange and web service results. REST (Representational State Transfer) APIs, configuration files, and NoSQL databases such as MongoDB, Redis, and Cassandra use the JSON format due to its flexible format for data exchange. It has an easy-to-parse data format that has a human-readable structure that most programming languages can parse using in-built libraries. Use the JSON files for storing and retrieving configuration data that an automation might reference during runtime to determine server, environment-specific, or folder-share details. The flexible structure of JSON accommodates various data types and complex data hierarchies.
The JSON utilities package integrate the automation workflows with web services and APIs that use JSON for data exchange. You can use the extracted values in the downstream actions. The JSON utilities package supports file streaming capability allowing you to define a file variable that holds the file stream as the data source. For more information about file streaming, see File streaming using file variable.
The workflow sequence for using the actions in the JSON utilities package is as follows:
- Start the JSON session using the Start session action. Use this session name for all corresponding actions.
- Use the different actions available in the JSON utilities package to automate JSON-related tasks.
- End the session using the End session action to complete a task.
JSON data types
- Strings
- Numbers
- Object (JSON Object)
- Array
- Booleans
NULL is not supported in Automation 360. Therefore, when you extract JSON data and convert it to
a dictionary variable, any null values in the JSON string are not converted, as
dictionary variables do not support null values. However, if the JSON contains an
empty string ("") instead of null, it will be successfully converted to a dictionary
variable.Understanding JSON structures
In JSON, data is mainly stored in two structures:
- Objects: Objects in JSON are collections of key, value pairs enclosed in curly
braces {}. Each key is a string enclosed with quotes (““) followed by a colon (:) ,
and commas (,) are used to separate the key, value pairs.Example:
{"name ": "John", "age": "30", "city": Detroit} - Arrays: Arrays are ordered lists of values, enclosed in square brackets []. Values
within an array are separated by commas (,).Example:
["John", "Annie", "Shane"]
Actions in the JSON utilities package
| Action | Description |
|---|---|
| Start session | Start a new JSON session based on the specified JSON data source. See Start session action in JSON. |
| Add node value | Add a new node to the JSON specified in Start session data source. See Add node value. |
| Convert Dictionary to JSON | Converts the content of a Dictionary variable to JSON format. See Convert Dictionary to JSON. |
| Convert JSON to Dictionary | Extract the contents of the JSON data source to a Dictionary variable. See Convert JSON to Dictionary. |
| Get node list | Retrieves the list of nodes for a node path. See Get node list action in JSON. |
| Get nodes | Extracts the key values from the JSON source. See Get nodes in JSON |
| Get node value | Retrieves the value of a node from the JSON source. See Get node value action in JSON. |
| Update node value | Update the value of a node in the JSON data source. See Update node value. |
| Validate | Validates the syntax, structure, and schema of the JSON data source. See Validate action |
| End session | Closes a JSON session. See End session action in JSON. |