# "Unexpected token } in JSON at position 15"

**URL:** <https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613>\
**Category:** General\
**Created:** [11 June 2024 05:15 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613 "2024-06-11T05:15:38Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [11 June 2024 05:15 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/1 "2024-06-11T05:15:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 June 2024 05:34 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/2 "2024-06-11T05:34:33Z")

</div>

How do you expect help with that unless you show us what is in the function?

Copy/paste please. Not screen shot

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [11 June 2024 06:01 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/3 "2024-06-11T06:01:19Z")

</div>

[  
{  
"id": "1d68193f3cb34a9e",  
"type": "template",  
"z": "129ad6e53bd2b94a",  
"name": "format for InfluxDB",  
"field": "payload",  
"fieldType": "msg",  
"format": "handlebars",  
"syntax": "mustache",  
"template": "{\n "var2": {{payload.0}}\n}",  
"output": "json",  
"x": 770,  
"y": 880,  
"wires": [  
[  
"0051206264b989a4"  
]  
]  
}  
]

---

<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:** [11 June 2024 06:06 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/4 "2024-06-11T06:06:29Z")

</div>

> [@Mayur](#):
>
> {{payload.0}}

That syntax is for accessing array elements. Buffer parser is outputting an object. Use the copy path button to get the correct path

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path/value for any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [11 June 2024 06:30 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/5 "2024-06-11T06:30:04Z")

</div>

{  
"var1": {{payload.0}}  
}

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [11 June 2024 07:36 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/6 "2024-06-11T07:36:44Z")

</div>

Steve has shown you how to get the correct path to the value you require. Use the copy path button for the value you want and replace payload.0 with the correct path.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 June 2024 10:02 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/7 "2024-06-11T10:02:24Z")

</div>

What is going into the function and what do you want out?

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [13 June 2024 09:33 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/8 "2024-06-13T09:33:43Z")

</div>

Output value needs to be in the DegC. Can anyone please advise.

[  
{  
"id": "2d2ffc8049288890",  
"type": "buffer-parser",  
"z": "129ad6e53bd2b94a",  
"name": "",  
"data": "responseBuffer.buffer",  
"dataType": "msg",  
"specification": "spec",  
"specificationType": "ui",  
"items": [  
{  
"type": "floatbe",  
"name": "item1",  
"offset": 0,  
"length": 1,  
"offsetbit": 0,  
"scale": "1",  
"mask": ""  
}  
],  
"swap1": "",  
"swap2": "",  
"swap3": "",  
"swap1Type": "swap",  
"swap2Type": "swap",  
"swap3Type": "swap",  
"msgProperty": "payload",  
"msgPropertyType": "str",  
"resultType": "keyvalue",  
"resultTypeType": "return",  
"multipleResult": false,  
"fanOutMultipleResult": false,  
"setTopic": true,  
"outputs": 1,  
"x": 110,  
"y": 540,  
"wires": [  
[  
"cb8ce51e8601e37c",  
"ac13c52130b12689"  
]  
]  
}  
]

---

<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:** [13 June 2024 10:01 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/9 "2024-06-13T10:01:57Z")

</div>

Buffer parser outputs parsed numbers only (by design).

Formatting should occur wherever you wish to see it.

Are you attempting to display the value on a dashboard? in a database? in a log file?

---

<div class="post-metadata">

**Author:** ![Mayur](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Mayur](https://discourse.nodered.org/u/Mayur)\
**Post date:** [13 June 2024 11:52 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/10 "2024-06-13T11:52:13Z")

</div>

1st in node red debug window then to Influx DB and then Grafana

---

<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:** [13 June 2024 12:04 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/11 "2024-06-13T12:04:41Z")

</div>

In which case the correct thing to do is leave it as a number. If necessary add some meta data to describe the value.

Converting it to a string and formatting it with `" °C"` before storing in a database is gonna hurt you when you come to query the data or summarise it.

Formatting data should be done at the presentation side.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 June 2024 13:07 UTC](https://discourse.nodered.org/t/unexpected-token-in-json-at-position-15/88613/12 "2024-06-13T13:07:44Z")

</div>

The data you show from debug 21, `{item1: 0}` can be fed directly into the influxdb node, and will write the value 0 to the field called `item1`.
