QuickTip: Using the JSON Object Manager Package

  • 22 October 2020
  • 0 replies
  • 1525 views

Userlevel 6
Badge +9

 

In this session, we'll look at how to use the JSON Object Manager package available for download from Bot Store. This package can be used for retrieving data from the JSON response of a REST web service call, reading JSON config files, getting the length of an array object within a JSON, or for updating JSON values based on the value's key.

Note: If you are using Automation Anywhere A2019 Community Edition, this package has already been installed for you.

Reference Link: Please find the link to the JSON used in the video here. As is done in the video, you can use a REST Get action and use the provided GitHub URL to fetch the JSON.

Video Recap

  1. Initialize the Session
    1. Using the package starts with initializing a session. This means using the initialize action in conjunction with the full JSON (either from the response body of a REST call or after read from a JSON file itself)
    2. The initialize action validates that the JSON is valid, and will set you up for being able to query the JSON's values.
  2. Query the JSON
    1. Using the Query action, users can fill in the key for the value they wish to retrieve.
    2. The value will be returned in whatever form it exists in the JSON.
      1. This means if employees is an array, and employees was the value provided as the key for the query action, the entire array of employees would be returned.
    3. The Query action can also be used for getting the length of an array object. This functionality is especially helpful when looping through the objects in the array is needed.
      1. Returning the length is done by providing the array key with .length() at the end.
      2. Example: If employees is the array key, then employees.length() would return the number of objects in the array
  3. Update the JSON
    1. 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.
    2. Example: If updating the email address for the first employee in the array, the notation would be:
      1. Key: employees[0].email
      2. Value: updatedemail@automationanywhere.com

Resources

Hopefully, this intro to the JSON Object Manager package was helpful. For additional information on using the package, check out the package's documentation on the Bot Store listing page.


0 replies

Be the first to reply!

Reply