The JSON Object Manager Package is one of the most popular packages in Automation Anywhere’s Bot Store. This package enables developers to retrieve data from the JSON response of a REST web service call, read JSON config files, get the length of an array object within a JSON, or update JSON values based on the corresponding key.
To use different actions in the package, first, a session must be initialized so that you can start using the other actions in the package. This initialization should be done with the entire JSON object – which will be used for extracting/updating data in the remaining package actions.
This action also validates that the JSON is valid and will set it up for further actions to parse the JSON object.
Query the JSON
With this action, users can retrieve the value corresponding to a key.
For example, if phoneNumbers is an array, then the entire array will be returned as a String.
This action can be used within a Loop action to retrieve all the values within an array.
This action can also be used to get the length of an array object. Add .length() at the end of the key to retrieve the number of elements in an array.
Update the JSON
The Set action allows you to update the JSON used for the session by providing the defined key as well as the intended paired value.
Example: If you want to update the length in the first sentence which is inside the second object of the documents array, the notation would be:Key: documents.sentences.length
For more details about different actions in this package, refer to the Bot Store listing page, which also includes the link to a ReadMe file that details how all of the actions in the package can be used.
This package is super useful for retrieving values from JSON responses received from REST web service calls or for updating the elements of the JSON objects.
By using the JSON Object Manager package, you can:
Simplify interacting with JSON responses
Query a single JSON object from a bot (either on its own or in a loop)
Modify the JSON elements in an existing JSON object for updating settings files or preparing the JSON body for a REST Web Service POST request.
Quick Tip: Knowing how to use this package will help in an upcoming challenge, so please do try it out and gear up to solve the challenge using multiple approaches.
This package enables you to convert files between multiple formats for ease of modification, the distribution/storage of read-only file formats, or for compatibility requirements of other dependent applications. Read More