# Return a JSON from Template Node

**URL:** https://discourse.nodered.org/t/return-a-json-from-template-node/74264
**Category:** General
**Created:** [27 January 2023 14:50 UTC](https://discourse.nodered.org/t/return-a-json-from-template-node/74264 "2023-01-27T14:50:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![FeliceM](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@FeliceM](https://discourse.nodered.org/u/FeliceM)
#### Post date: [27 January 2023 14:50 UTC](https://discourse.nodered.org/t/return-a-json-from-template-node/74264/1 "2023-01-27T14:50:28Z")

</div>

I am trying to return a JSON from a template but I get errors when I set the template node to "Parsed JSON".  
The error says "Unexpected token : in JSON at position 13"  
This is the content of the template node:

```auto
"GPIO_status": "{{global.GPIOStatus}}"

```

It works if I use a string instead of the variable but I need to use the variable.

```auto
[
    {
        "id": "790ce3dd056171ab",
        "type": "http in",
        "z": "2879f16a7e5f317b",
        "name": "Input from KIosk",
        "url": "/api/9999",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 600,
        "y": 980,
        "wires": [
            [
                "74a459e814c726ae"
            ]
        ]
    },
    {
        "id": "3b704fe84da208bb",
        "type": "http response",
        "z": "2879f16a7e5f317b",
        "name": "",
        "statusCode": "200",
        "headers": {},
        "x": 960,
        "y": 980,
        "wires": []
    },
    {
        "id": "74a459e814c726ae",
        "type": "template",
        "z": "2879f16a7e5f317b",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "\"GPIO_status\": \"{{global.GPIOStatus}}\"\n",
        "output": "json",
        "x": 780,
        "y": 980,
        "wires": [
            [
                "3b704fe84da208bb"
            ]
        ]
    }
]

```

---

<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: [27 January 2023 15:04 UTC](https://discourse.nodered.org/t/return-a-json-from-template-node/74264/2 "2023-01-27T15:04:54Z")

</div>

> [@FeliceM](#):
>
> This is the content of the template node:
> 
> ```auto
> "GPIO_status": "{{global.GPIOStatus}}"
> 
> ```

Even after the global var is replaced by mustache, that is not valid JSON.

[https://codebeautify.org/jsonvalidator/y234d047e](https://codebeautify.org/jsonvalidator/y234d047e)

Try wrapping it in { curly } brackets

---

<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: [10 February 2023 15:05 UTC](https://discourse.nodered.org/t/return-a-json-from-template-node/74264/3 "2023-02-10T15:05:10Z")

</div>

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