jsonDOMGet

Version 22.0.8473


jsonDOMGet

Version 22.0.8473


Get values from a JSON document.

Required Parameters

  • map:*: This set of inputs contains one or more mappings of an attribute name and a jsonpath that specifies the value or values to retrieve from the JSON document.

Optional Parameters

  • uri: A JSON file URI.
  • handle: The handle of the specified JSON reader.
  • repeatelement#: The jsonpath to an element that is repeated in the document.
  • repeatmode: The push mode. The allowed values are ITEM and ARRAY. The default value is ITEM.

Output Attributes

  • *: The elements and the attributes found within each item element.

Example

Consider the JSON data below, which is passed as input data to a Script Connector in CData Arc:

{
    "name": "Nancy",
    "age": "31",
    "gender": "Female"
}

In this Script Connector, you can invoke jsonDOMGet in ArcScript to retrieve the name and age of the person defined in this data and add them as headers to a message in CData Arc. The ArcScript code below shows an example of how to do this:

<arc:set attr="json.uri" value="[Filepath]" />
  <arc:set attr="json.map:name" value="/json/name" />
  <arc:set attr="json.map:age" value="/json/age" />
  <arc:call op="jsonDomGet" in="json" out="result">
    <!-- result.name and result.age has the value of the json path because map:name and map:age was 
         set in the input to the op, and result is the name of the output item. Once this
         op closes, result falls out of scope, so use your value here --> 
    <arc:set attr="output.header:personsname" value="[result.name]" />
    <arc:set attr="output.header:personsage" value="[result.age]" />
  </arc:call>

After this code executes, CData Arc pushes the file with the newly added headers as output down the flow.