> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arc.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# jsonDOMSearch

> Loops over the elements in an input JSON document using a jsonpath to enumerate repeating structures.

Loop over the elements in an input JSON document.

## Required Parameters

* **jsonpath**: The 1-based index jsonpath of the specified segment to loop over (for example, `<arc:set attr="myinputitem.jsonpath" value="/json/foo/" />`).

## Optional Parameters

* **uri**: A JSON file URI (for example, `http://mydomain.com/resources/somedata.json`, `/tmp/myfile.json` or `[FilePath]`).
* **text**: A readable handle reference to the JSON data. This handle is created by the [jsonOpen](./op-json-open) 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](./op-json-open) for details and examples.

## Output Attributes

* **jsonpath**: The 1-based index jsonpath(s) of the output item relative to the jsonpath set on the input item.
* **name**: Returns the name of the specified element being looped over (for example, `[myoutitem.name]` resolves to the name of the `foo` JSON element, which is `foo`).
* **type**: Returns the data type of the specified element being looped over (for example, `[myoutitem.type]` resolves to `STRING` if the `foo` element has a string value).

## Example

Consider this JSON passed in as an input file:

```json theme={null}
{
    "hello": "world",
    "colors": [
        {
            "color": "yellow",
            "example": "banana"
        },
        {
            "color": "red",
            "example": "apple"
        },
        {
            "color": "orange",
            "example": "orange"
        }
    ]
}
```

You can use the jsonDOMSearch operation to enumerate over all the objects in the `colors` array, as shown below:

```xml theme={null}
<!-- Setting the input uri and jsonpath -->
<arc:set attr="json.uri" value="[FilePath]" />
<arc:set attr="json.jsonpath" value="/json/colors/" />

<!-- Calling the operation, passing in the json item and creating a "result" output item --> 
<arc:call op="jsonDOMSearch" in="json" >
  <!-- Inside the call you can reference elements at paths relative to the input "jsonpath" -->
  <!-- In this example each color and example from each object inside the "colors" array is logged -->
  <arc:set attr="_log.info" value="Color = [jsonpath(color)]" />
  <arc:set attr="_log.info" value="Example = [jsonpath(example)]" />
</arc:call>

<!-- Setting the output file and pushing the file out -->
<arc:set attr="output.filepath" value="[FilePath]" />
<arc:push item="output" />
```

The output in the application log looks like this:

<img src="https://mintlify.s3.us-west-1.amazonaws.com/cdata-arc/26.2/self-hosted/en/scripting/operations/assets/images/jsonDOMSearch.png" width="600" />
