Required Parameters
- map:*: A set of one or more inputs where the name of the mapped parameter proceeds the colon (for example,
map:foo), and the value is the jsonpath to the desired json element in the document (see Examples for details).
Optional Parameters
- uri: A JSON file URI. This can be a dynamic file reference such as
[FilePath]for the input file, a static filepath on disk, or a public URL for a JSON file. - text: A readable handle reference to the JSON data. This handle is created by the jsonOpen operation and is helpful when the input JSON is not a file or raw text, or when it is necessary to perform multiple actions that access the file data of the document.
- handle: A readable handle reference to the JSON data. This handle is created by the jsonOpen operation and is only necessary when the target JSON is not an input file. See jsonOpen for details and examples.
- repeatelement#: The jsonpath to an element that is repeated in the document.
- repeatmode: Defines the way in which the
repeatelement#values are stored on the output item. The allowed values areITEMandARRAY. When set toITEM(the default), the values found from the repeat element are stored as individual attributes on each output item the operation produces. When set toARRAY, the values found from the repeat element are stored as array attributes on a single output item and need to be accessed via their 1-based index (for example,[result.color#2]would refer to the second value in thecolorattribute of the result item).
Output Attributes
- *: The output values from the JSON elements that were mapped using the map parameter. These are accessed by referencing the output item and the name of the mapped input item (for example,
[results.foo]). The name of the output item (resultsin this case) is determined by the user. See Examples for additional context.
Examples
Retrieve Values from a JSON Document
Consider the JSON data below, which is passed as input data to a Script connector in :name and age of the person defined in this data and add them as headers to a message in . The Script code below shows an example of how to do this:
Access a Specific Index of an Array in a JSON Object
Users often need to access a specific index of an array in JSON data. For example, you might want to access theid of the second order object in the orders array in the JSON object below, which is passed as an input file to a Script connector.
id of a specific order using the 1-based index jsonpath to an element present in one of the objects in the orders array. The Script code below shows an example of how to do this:
Use the repeatelement Parameter
Consider the JSON data below, which is passed as an input file to a Script Connector:repeatelement# parameter is used to define the element that has repeating values. In this example the color and example values are repeated in the /json/colors element, which is a JSON array. When you set repeatelement#, the jsonDOMGet operation loops over the values that are present in that element.
The repeatmode parameter defines the way in which the repeatelement# values are stored as output. When set to ITEM (the default), the values found by the repeat element are stored as individual attributes on the output item. When set to ARRAY, the values found by the repeat element are stored as array attributes on the output item and need to be accessed via their 1-based index (for example, [result.color#2] would resolve to red and result.example#2 would resolve to apple).