# Iterating over a JSON array

**URL:** <https://the.fmsoup.org/t/iterating-over-a-json-array/3612>\
**Category:** Questions\
**Created:** [June 25, 2023, 5:12pm UTC](https://the.fmsoup.org/t/iterating-over-a-json-array/3612 "2023-06-25T17:12:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinD](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@kevinD](https://the.fmsoup.org/u/kevinD)\
**Post date:** [June 25, 2023, 5:12pm UTC](https://the.fmsoup.org/t/iterating-over-a-json-array/3612/1 "2023-06-25T17:12:42Z")

</div>

Hi all,  
Want to iterate over a JSON array and don't know how to formulate the JSONgetElement.  
This works in the data viewer:

```auto
JSONGetElement ( CustomFunc::JSON;"rss.channel.item[5].guid" )

```

But when I try to do this , I get an error.

```auto
JSONGetElement ( CustomFunc::JSON;"rss.channel.item[$index].guid" )

```

i.e When I insert the local variable $index , I get an error - like so:  
? \* Offset 17 in "rss.channel.item[$index].guid"  
JSON path syntax error.

So how do I do this ?  
thanks  
Kevin

---

<div class="post-metadata">

**Author:** ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)\
**Post date:** [June 25, 2023, 7:45pm UTC](https://the.fmsoup.org/t/iterating-over-a-json-array/3612/2 "2023-06-25T19:45:23Z")

</div>

`JSONGetElement ( CustomFunc::JSON;"rss.channel.item[" & $index & "].guid" )`

you need to use $index and not just put $index as text there.  
JavaScript doesn't know what $index should be.

---

<div class="post-metadata">

**Author:** ![kevinD](https://avatars.discourse-cdn.com/v4/letter/k/85e7bf/32.png) [@kevinD](https://the.fmsoup.org/u/kevinD)\
**Post date:** [June 26, 2023, 2:01pm UTC](https://the.fmsoup.org/t/iterating-over-a-json-array/3612/3 "2023-06-26T14:01:02Z")

</div>

Thanks a lot.  
Yeah, it was that part that I was not getting. Works great now .  
Kevin
