"Unexpected token } in JSON at position 15"

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

Copy/paste please. Not screen shot

"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": [

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) 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.


"var1": {{payload.0}}

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.

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

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": [

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?

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

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.

1 Like

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.