Note that version 1.1 of this Processor is deprecated. For better experience, rather use version 1.2
The linked section explains the main upgrades and improvements in version 1.2



Overview

Creates from a single text column (XML/JSON format) an output dataset. The content of the output dataset is given by XPATH /JSONPath expressions, where each expression creates one column.

XPATH (JSONPath) uses a non-XML (non-JSON) syntax to provide a flexible way of addressing different parts of an  XML (JSON) document.


More information about XPATH and JSONPath.



Input

The input table should contain the JSON or XML text to parse. It can have multiple columns. The column to parse is specified by the Processor.


Note that One column should contain the same text format.



Configuration

Output

The output table contains the result corresponding to the XPATH / JSONPATH expressions specified in the Processor configuration. Each expression result is stored in a separate column.


Example

Workflow

Example Input

The input table is composed of two columns:

  • The first column contains two JSON Objects targeted by the first parser.
  • The second column contains an XML format text targeted by the second parser.

The used code is shown bellow:


First JSON Object

{ 
   "title":{ 
      "text":"My Chart"
   },
   "subtitle":{ 
      "text":"My Untitled Chart"
   },
   "chart":{ 
      "type":"line",
      "inverted":false
   },
   "series":[ 
      { 
         "name":"Y"
      },
      { 
         "name":"Z"
      }
   ]
}


Second JSON Object

{ 
   "id":"timeschartkpiTimesElement",
   "type":"highcharts",
   "tempCustomSql":"SELECT * FROM InputTable",
   "source":"casetableDatasource",
   "config":{ 
      "title":{ 
         "text":""
      }
   }
}

XML

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Work on issue QA-100</body>
</note>

Example Configuration

We used two parsers respectively for both the JSON and the XML columns, and added two paths in each parser resulting in two output columns.


JSON Parsing Processor


XML Parsing Processor



Result


XML / JSON Parsing v1.2 Processor

Input Data

For the upcoming examples, we'll be using the following input JSON code

{
   "totalItems":28228,
   "page":0,
   "ipp":50,
   "paginated":true,
   "items":[
      {
         "foo":{
            "foo2":"bar"
         }
      },
      {
         "foo":{
            "foo2":"bar2"
         }
      },
      {
         "foo3":{
            "bar3":"bar4"
         }
      }
   ]
}


Improvements

Remove Unnecessary Quotes

In case the result is a single string, the Processor removes the unwanted quotes.

The following figures show the Processor configuration for the JSON path expression and the results in both versions 1.1 and 1.2


Add Null to Empty Cells

If a JSONPATH query does not match and has no result, the Processor will add NULL into the cell instead of dropping the whole row


This upgrade can help overcome multiple issues faced with the old version of the Processor.

Version 1.1 fails to handle cases where the column containing JSON had missing values (empty strings, NULL). It requires that all XPATH / JSONPATH expressions specified in the Processor configuration must return a non-empty result in every row of the input column.
If this condition is not fulfilled, the Processor fails to execute.

The following example shows a successful case using version v1.2



In this same example, version 1.1 of the Processor fails to execute.