# Selec a value from a variable key

**URL:** <https://discourse.nodered.org/t/selec-a-value-from-a-variable-key/36920>\
**Category:** General\
**Created:** [3 December 2020 01:52 UTC](https://discourse.nodered.org/t/selec-a-value-from-a-variable-key/36920 "2020-12-03T01:52:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leoborlot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leoborlot/32/31253_2.png) [@leoborlot](https://discourse.nodered.org/u/leoborlot)\
**Post date:** [3 December 2020 01:52 UTC](https://discourse.nodered.org/t/selec-a-value-from-a-variable-key/36920/1 "2020-12-03T01:52:03Z")

</div>

Hi guys. I have thie Json Payload.

{  
"total": "1",  
"contacts": {  
"5734": {  
"isPublished": true,  
"dateAdded": "2020-10-05T13:51:52+00:00",  
"dateModified": "2020-12-02T23:10:17+00:00",  
"createdBy": null,  
"createdByUser": null,  
"modifiedBy": 3,  
"modifiedByUser": "Leo Borlot",  
"id": 5734,  
"points": 0,  
"color": null,  
"fields": {  
"core": {  
"points": {  
"id": "9",  
"label": "Points",  
"alias": "points",  
"type": "number",  
"group": "core",  
"object": "lead",  
"is\_fixed": "1",  
"properties": "a:0:{}",  
"default\_value": null,  
"value": "0",  
"normalizedValue": "0"  
},

How May I selec the point.id if I don´t know whit is the value of contact number?  
Ive try this: payload.contacts[0].fields.core.points.id  
But it, dont works...

Sorry if this is very newbie...

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [3 December 2020 02:14 UTC](https://discourse.nodered.org/t/selec-a-value-from-a-variable-key/36920/2 "2020-12-03T02:14:19Z")

</div>

There is a json query library called **Jsonata** that can be accessed through the **Change node**.  
In cases like your example it is very very useful.

You can use ` **.points.id` as an expression that basically filters out all** points.id** values from your Json at any level deep. hence the \*\* wildcards.

**Example:**

```auto
[{"id":"fc99ef62.bb6938","type":"debug","z":"f19dd631.0088b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":460,"wires":[]},{"id":"b5689c00.f84178","type":"inject","z":"f19dd631.0088b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"total\":\"1\",\"contacts\":{\"5734\":{\"isPublished\":true,\"dateAdded\":\"2020-10-05T13:51:52+00:00\",\"dateModified\":\"2020-12-02T23:10:17+00:00\",\"createdBy\":null,\"createdByUser\":null,\"modifiedBy\":3,\"modifiedByUser\":\"Leo Borlot\",\"id\":5734,\"points\":0,\"color\":null,\"fields\":{\"core\":{\"points\":{\"id\":\"9\",\"label\":\"Points\",\"alias\":\"points\",\"type\":\"number\",\"group\":\"core\",\"object\":\"lead\",\"is_fixed\":\"1\",\"properties\":\"a:0:{}\",\"default_value\":null,\"value\":\"0\",\"normalizedValue\":\"0\"}}}}}}","payloadType":"json","x":240,"y":460,"wires":[["1718a348.eb841d","5186e917.73bd28"]]},{"id":"1718a348.eb841d","type":"change","z":"f19dd631.0088b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"**.points.id","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":460,"wires":[["fc99ef62.bb6938"]]},{"id":"5186e917.73bd28","type":"debug","z":"f19dd631.0088b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":380,"y":360,"wires":[]}]

```

You can read more on JSONata operators [here](http://docs.jsonata.org/path-operators)

---

<div class="post-metadata">

**Author:** ![leoborlot](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leoborlot/32/31253_2.png) [@leoborlot](https://discourse.nodered.org/u/leoborlot)\
**Post date:** [3 December 2020 02:20 UTC](https://discourse.nodered.org/t/selec-a-value-from-a-variable-key/36920/3 "2020-12-03T02:20:07Z")

</div>

Thanks man, this is all new for me, I will learn more about JSONATA.

Your sugestion works very well here!!

---

<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:** [17 December 2020 02:20 UTC](https://discourse.nodered.org/t/selec-a-value-from-a-variable-key/36920/4 "2020-12-17T02:20:18Z")

</div>

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