Parse Data Action

Formatter's Parse Data action can be used to extract specific data from a blob of JSON/XML data. This action is ideally used in conjunction with the Webhooks 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 to this documentation

Did this answer your question?