JSON package
- Updated: 2024/07/23
JSON package
The JSON package is useful for working with JSON data. It allows you to effectively manipulate 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.
This package plays a crucial role in seamlessly integrating automation workflows with web services and APIs that use JSON for data exchange.
Benefits
- JavaScript Object Notation (JSON) is a lightweight, easy-to-understand, extensible format for storing, transporting, and retrieving data. JSON uses key-value pairs of data and delivers faster data interchange and web service results.
- Most REST Web Services (APIs), some configuration files, and many NoSQL databases such as MongoDB commonly use JSON because of its flexible format for data exchange. It is text-based, lightweight, and has an easy-to-parse data format, which means it requires no additional code to understand and interpret the provided data.
- JSON files can be great for storing and retrieving configuration data your automation might reference when determining server, environment-specific, or folder-share details.
- JSON's flexible structure efficiently accommodates various data types and complex data hierarchies.
JSON data types
The values in JSON must be of following data type:
- Strings
- Numbers
- Object (JSON Object)
- Array
- Booleans
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"]
Using JSON package
Use the actions in the JSON package in the following
order:
- 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 package to automate JSON related tasks.
- End the session using the End session action to complete a task.
Actions in the JSON package
The JSON package includes the following actions:
Action | Description |
---|---|
Add node value | See Add node value. |
Convert Dictionary to JSON | See Convert Dictionary to JSON. |
End session | See End session action in JSON. |
Get node list | See Get node list action in JSON. |
Get node value | See Get node value action in JSON. |
Convert JSON to Dictionary | See Convert JSON to Dictionary. |
Start session | See Start session action in JSON. |
Update node value | See Update node value. |