On August 11, 2023, Cisco announced that Cisco SecureX will go end-of-life on July 31, 2024. The content in this Github repository will not be actively maintained following this announcement.

Read Table from JSON/Text/XML

Category: Table

If you want to parse data from an API so that you can iterate over multiple objects, you’ll want to use one of the Read Table from ... activities. These activities allow you to convert JSON, XML, or delimited text into tables. Once you’ve created a table, you can use a For Each loop to iterate over its rows. You can also use these activities to create an empty table to add data to.


Notes

  • Each of these activities has an option to populate column headers from their source data. We don’t recommend using this option because the columns will only be populated at run time (since the workflow doesn’t know what the source data will be until it runs). If you choose to populate headers automatically, you won’t be able to use the columns when creating a For Each loop. You should always explicitly define your columns by clicking Add under the Columns to Read properties section and adding each column.
  • Each of these activities has an option to Persist Table. If you want to be able to make changes to the table that’s created, you need to persist it. Otherwise, you’ll only be able to read from the table.

Read Table from Text

This activity allows you to create a table from plain, delimited text such as comma-separated values. Here’s a sample of some text you could read into a table using this activity:

id,name,username,email
1,Leanne Graham,lgraham,leanne@company.com
2,Ervin Howell,ehowell,ervin@company.com
3,Clementine Bauch,wrongusername,clementine@company.com
4,Patricia Lebsack,plebsack,patricia@company.com

Be sure to read the notes at the top of this page as they apply to each of these activities!


Read Table from JSON

This activity allows you to create a table from a list of JSON-formatted objects. To tell the activity which objects to select, you need to provide a JSON path (see the JSONPath Query activity’s documentation for more information about JSON Path). A JSON path to select all objects in the sample data below would be: $.

[
  {
    "id": 1,
    "name": "Leanne Graham",
    "username": "lgraham",
    "email": "leanne@company.com"
  },
  {
    "id": 2,
    "name": "Ervin Howell",
    "username": "ehowell",
    "email": "ervin@company.com"
  },
  ...
]

Be sure to read the notes at the top of this page as they apply to each of these activities!


Read Table from XML

This activity allows you to create a table from a list of XML-formatted objects. To tell the activity which objects to select, you need to provide an XML path (see the XPath Query activity’s documentation for more information about XML path). An XML path to select all objects in the sample data below would be: /root/row

<?xml version="1.0" encoding="UTF-8" ?>
<root>
  <row>
    <id>1</id>
    <name>Leanne Graham</name>
    <username>lgraham</username>
    <email>leanne@company.com</email>
  </row>
  <row>
    <id>2</id>
    <name>Ervin Howell</name>
    <username>ehowell</username>
    <email>ervin@company.com</email>
  </row>
  ...
</root>

Be sure to read the notes at the top of this page as they apply to each of these activities!


Creating an Empty Table

A simple trick to creating an empty table is to use the Read Table from JSON activity with an empty list as the source data:

[]

Sample Workflows

The following sample workflows are available in our repository’s workflows folder to help you get familiar with these activities. These can be imported using the instructions here or you can view the workflow in GitHub by clicking on it.