# Extracting text from object using mustache template

**URL:** <https://discourse.nodered.org/t/extracting-text-from-object-using-mustache-template/79370>\
**Category:** General\
**Created:** [23 June 2023 13:11 UTC](https://discourse.nodered.org/t/extracting-text-from-object-using-mustache-template/79370 "2023-06-23T13:11:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [23 June 2023 13:11 UTC](https://discourse.nodered.org/t/extracting-text-from-object-using-mustache-template/79370/1 "2023-06-23T13:11:29Z")

</div>

```auto
[{"id":"f9a5770faf447e4d","type":"inject","z":"400bc99efba52b23","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"Text\":\"SP-4 is Running Since 17 Min\"},{\"Text\":\"Juice Line is Running Since 9 Min\"},{\"Text\":\"14 Track is Running Since 9 Min\"},{\"Text\":\"New 8 Track is Running Since 4 Min\"},{\"Text\":\"AP-2 is Running Since 1 Min\"},{\"Text\":\"Mespack-2 is Running Since 155 Min\"},{\"Text\":\"Vardaan is Running Since 81 Min\"}]","payloadType":"json","x":3840,"y":1200,"wires":[["33e60c1e608595c5","5f5dd1deb2c5a86f"]]},{"id":"5f5dd1deb2c5a86f","type":"template","z":"400bc99efba52b23","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload[0].Text}}\n{{payload[1].Text}}\n{{payload[2].Text}}\n{{payload[3].Text}}\n{{payload[4].Text}}\n{{payload[5].Text}}\n{{payload[6].Text}}","output":"str","x":4050,"y":1200,"wires":[["b4431937280518bb"]]},{"id":"b4431937280518bb","type":"debug","z":"400bc99efba52b23","name":"debug 388","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":4220,"y":1200,"wires":[]}]

```

i am trying to extract only one element from an array of objects. but this seems not working. what is the mistake i am doing ?

this is my template node

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

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4ead28eb1ed914056fb409a9408d9a025c8ea3e4.png)

i am expecting to get result like this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/3/b3916ff7b164e803e95f1fc76c63d93c5afe5f59.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 June 2023 13:26 UTC](https://discourse.nodered.org/t/extracting-text-from-object-using-mustache-template/79370/2 "2023-06-23T13:26:21Z")

</div>

FYI: This has been asked and answered [many many times already](https://discourse.nodered.org/search?q=mustache%20array)

Dont use `[x]`, use `.x.` instead

```auto
{{payload.0.Text}}
{{payload.1.Text}}
{{payload.2.Text}}
{{payload.?.Text}}
and so on

```

Even better:

```auto
{{#payload}}
     {{Text}
{{/payload}}

```

---

<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:** [7 July 2023 13:27 UTC](https://discourse.nodered.org/t/extracting-text-from-object-using-mustache-template/79370/3 "2023-07-07T13:27:12Z")

</div>

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