# JSONata absurdities

**URL:** <https://discourse.nodered.org/t/jsonata-absurdities/25220>\
**Category:** General\
**Created:** [21 April 2020 01:44 UTC](https://discourse.nodered.org/t/jsonata-absurdities/25220 "2020-04-21T01:44:23Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![T0T4R4](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/t0t4r4/32/10850_2.png) [@T0T4R4](https://discourse.nodered.org/u/T0T4R4)\
**Post date:** [21 April 2020 01:44 UTC](https://discourse.nodered.org/t/jsonata-absurdities/25220/1 "2020-04-21T01:44:24Z")

</div>

Hi guys,

Could someone explain me the following JSONAta absurdity ?

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/c/8ceb688160ddfb43009a28113b4dd9a5124501d0.png)

Thanks heaps

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [21 April 2020 07:05 UTC](https://discourse.nodered.org/t/jsonata-absurdities/25220/2 "2020-04-21T07:05:54Z")

</div>

Because it's Tuesday

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [21 April 2020 10:01 UTC](https://discourse.nodered.org/t/jsonata-absurdities/25220/3 "2020-04-21T10:01:21Z")

</div>

you need to use [% (Parent)](https://docs.jsonata.org/path-operators#-parent)

This will select the 'parent' of the current context value. Here, we define 'parent' to be the enclosing object which has the property representing the context value.

> **`%`**** (Parent)**  
> This is the only operation which searches 'backwards' in the input data structure. It is implemented by static analysis of the expression at [compile time](https://docs.jsonata.org/embedding-extending#jsonatastr) and can only be used within expressions that navigate through that target parent value in the first place. If, for any reason, the parent location cannot be determined, then a static error (S0217) is thrown.

Replace `items[item]` with `items[%.item]`  
since `items` and `item` are both at the same level in the hierarchy, and using `items` starts you down one leg of the hierarchy, to get `item` you need to go back up so you can access `item`

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [21 April 2020 13:03 UTC](https://discourse.nodered.org/t/jsonata-absurdities/25220/4 "2020-04-21T13:03:22Z")

</div>

Alternatively, for older Node-RED/JSONata versions: `items[$$.item]`, where `$$` is always referencing to the root object passing in.The Parent operator is by far the preferred solution, and I'm glad it got added; I think it was Steve who came up with the `%` syntax. For older versions though, that's not available, and paging to the object from root level or lower level is often best there; it helps to set variables as you go down the tree, so you have higher level parts of the tree available through that variable. But again, `%.item` is preferred in the newer version, this is for backwards compatible answers.

---

<div class="post-metadata">

**Author:** ![T0T4R4](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/t0t4r4/32/10850_2.png) [@T0T4R4](https://discourse.nodered.org/u/T0T4R4)\
**Post date:** [29 April 2020 04:36 UTC](https://discourse.nodered.org/t/jsonata-absurdities/25220/5 "2020-04-29T04:36:01Z")

</div>

Thanks heaps guys, btw who is Steve ?

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [29 April 2020 05:19 UTC](https://discourse.nodered.org/t/jsonata-absurdities/25220/6 "2020-04-29T05:19:37Z")

</div>

> [@T0T4R4](#):
>
> btw who is Steve ?

That would be @shrickus

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 June 2020 05:19 UTC](https://discourse.nodered.org/t/jsonata-absurdities/25220/7 "2020-06-28T05:19:47Z")

</div>

Closed on 28 June 2020 05:19 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
