Formatter - Parse Data

Parse Data Action

The Formatter - Parse Data action can be use to extract specific data from a blob of JSON/XML data. This action is ideally used in conjunction with the Webhook app or any other app that provides JSON/XML data as output.

We use this action to specify a key and get the corresponding value for it extracted out from the available data

The below Images shows the Formatter app - Parse Data action where we specify the input data format, the data coming in and the specific key that we need to extract the value for:

Using the Action

We'll consider an example each for JSON and XML to understand how this action works:

JSON

Sample Data

{
  "store": {
    "book": [
      {
        "category": "reference",
        "author": "Nigel Rees",
        "title": "Sayings of the Century",
        "price": 8.95
      },
      {
        "category": "fiction",
        "author": "Evelyn Waugh",
        "title": "Sword of Honour",
        "price": 12.99
      },
      {
        "category": "fiction",
        "author": "Herman Melville",
        "title": "Moby Dick",
        "isbn": "0-553-21311-3",
        "price": 8.99
      },
      {
        "category": "fiction",
        "author": "J. R. R. Tolkien",
        "title": "The Lord of the Rings",
        "isbn": "0-395-19395-8",
        "price": 22.99
      }
    ],
    "bicycle": {
      "color": "red",
      "price": 19.95
    }
  }
}

Extracting values from JSON

Here, we are extracting the price for the first book in the store:

Extracted Value

We get the price as expected.

XML

We'll also go through the same example for XML data

Sample Data

<store>
  <book>
    <category>reference</category>
    <author>Nigel Rees</author>
    <title>Sayings of the Century</title>
    <price>8.95</price>
  </book>
  <book>
    <category>fiction</category>
    <author>Evelyn Waugh</author>
    <title>Sword of Honour</title>
    <price>12.99</price>
  </book>
  <book>
    <category>fiction</category>
    <author>Herman Melville</author>
    <title>Moby Dick</title>
    <isbn>0-553-21311-3</isbn>
    <price>8.99</price>
  </book>
  <book>
    <category>fiction</category>
    <author>J. R. R. Tolkien</author>
    <title>The Lord of the Rings</title>
    <isbn>0-395-19395-8</isbn>
    <price>22.99</price>
  </book>
  <bicycle>
    <color>red</color>
    <price>19.95</price>
  </bicycle>
</store><br>

Extracting values from XML

Here, we are extracting the price for the first book in the store:

Extracted Value

We get the price as expected.

Further Reading

For more advanced extraction scenarios, refer this documentation. Please note that we only accept JSONPath as highlighted in the documentation and XPath is not supported.