# JSONata help to extract valuefrom array then object

**URL:** <https://discourse.nodered.org/t/jsonata-help-to-extract-valuefrom-array-then-object/28065>\
**Category:** General\
**Created:** [9 June 2020 15:39 UTC](https://discourse.nodered.org/t/jsonata-help-to-extract-valuefrom-array-then-object/28065 "2020-06-09T15:39:51Z")\
**Posts on this page:** 6\
**Page:** 1

<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:** [9 June 2020 15:39 UTC](https://discourse.nodered.org/t/jsonata-help-to-extract-valuefrom-array-then-object/28065/1 "2020-06-09T15:39:52Z")

</div>

I have a msg

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/7/7794c2f08c6311125b5ab82ff7dca2b012d1f1db.png)

and I'd like to extract the value of col1 using JSONata and as usual - not being successful

present (not working attempt)

`payload[0].col1`

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [9 June 2020 16:18 UTC](https://discourse.nodered.org/t/jsonata-help-to-extract-valuefrom-array-then-object/28065/2 "2020-06-09T16:18:51Z")

</div>

```auto
payload.0.col1 ?

```

[EDIT]

payload["0"].col1

---

<div class="post-metadata">

**Author:** ![janvda](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/janvda/32/234_2.png) [@janvda](https://discourse.nodered.org/u/janvda)\
**Post date:** [9 June 2020 19:25 UTC](https://discourse.nodered.org/t/jsonata-help-to-extract-valuefrom-array-then-object/28065/3 "2020-06-09T19:25:16Z")

</div>

**Tip:** share the JSON object as text (not as an image) so that we can test the JSONata query in [https://try.jsonata.org/](https://try.jsonata.org/)

at first sight I would expect your JSONata being correct but can't test it.

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [9 June 2020 19:36 UTC](https://discourse.nodered.org/t/jsonata-help-to-extract-valuefrom-array-then-object/28065/4 "2020-06-09T19:36:01Z")

</div>

As I said above in my edit.

```auto
[{"id":"83bd3483.dd4038","type":"inject","z":"46eb32e6.39048c","name":"","topic":"","payload":"[{\"col1\":\"Seven missed voilce calls\",\"col2\":\"Note3\"}]","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":60,"wires":[["9ec88448.5bca88"]]},{"id":"9ec88448.5bca88","type":"change","z":"46eb32e6.39048c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[\"0\"].col1\t\t\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":60,"wires":[["f4f0bd72.cd2fe"]]},{"id":"f4f0bd72.cd2fe","type":"debug","z":"46eb32e6.39048c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":60,"wires":[]}]

```

---

<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:** [9 June 2020 20:55 UTC](https://discourse.nodered.org/t/jsonata-help-to-extract-valuefrom-array-then-object/28065/5 "2020-06-09T20:55:22Z")

</div>

Turns out I had a logic fault because I forgot that my text wasn't in msg.payload but in msg.oldPayload #NogginMe

Both  
`oldPayload[0].col1`  
and  
`oldPayload["0"].col1`

work fine 🙂

---

<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:** [23 June 2020 20:55 UTC](https://discourse.nodered.org/t/jsonata-help-to-extract-valuefrom-array-then-object/28065/6 "2020-06-23T20:55:27Z")

</div>

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