# \[Solved \]Selecting an object in an array of objects with JSONata with incoming msg.payload

**URL:** <https://discourse.nodered.org/t/solved-selecting-an-object-in-an-array-of-objects-with-jsonata-with-incoming-msg-payload/5807>\
**Category:** General\
**Created:** [14 December 2018 13:17 UTC](https://discourse.nodered.org/t/solved-selecting-an-object-in-an-array-of-objects-with-jsonata-with-incoming-msg-payload/5807 "2018-12-14T13:17:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![IoTPlay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iotplay/32/40_2.png) [@IoTPlay](https://discourse.nodered.org/u/IoTPlay)\
**Post date:** [14 December 2018 13:17 UTC](https://discourse.nodered.org/t/solved-selecting-an-object-in-an-array-of-objects-with-jsonata-with-incoming-msg-payload/5807/1 "2018-12-14T13:17:18Z")

</div>

I have this object / array in flowContext named `dig2`:

```auto
{"registry":
    [
        { "Catid" : "Air-1a",
          "Name" : "Air",
          "ValueName" : "Humidity",
          "Loc" : "North Quad"},

        { "thing_id" : "Irr-6",
          "Name" : "Irrigation",
          "ValueName" : "Auto",
          "Loc" : "Garden"}
   ]
}

```

With a Change node, using JSONata expression below, it selects only the 2nd object, and sends to msg.payload:

```auto
$flowContext('dig2.registry')[Name = 'Irrigation']

```

But, I would like to use an incoming msg.payload before the change node to do the selection, neither of below 2 JSONata statements works, any ideas?

```auto
$flowContext('dig2.registry')[Name = payload]

```

or

```auto
$flowContext('dig2.registry')[Name = $.payload]

```

Per other reported posts, I have also tried `payload.[0]`, `payload.[1]`, and `payload."1"` - also not working?

---

<div class="post-metadata">

**Author:** ![IoTPlay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/iotplay/32/40_2.png) [@IoTPlay](https://discourse.nodered.org/u/IoTPlay)\
**Post date:** [14 December 2018 13:32 UTC](https://discourse.nodered.org/t/solved-selecting-an-object-in-an-array-of-objects-with-jsonata-with-incoming-msg-payload/5807/2 "2018-12-14T13:32:11Z")

</div>

Solved, from another post, it should be:

```auto
$flowContext('dig2.registry')[Name = $$.payload]

```
