# How to send .json strings over MQTT

**URL:** <https://discourse.nodered.org/t/how-to-send-json-strings-over-mqtt/46166>\
**Category:** General\
**Created:** [24 May 2021 15:51 UTC](https://discourse.nodered.org/t/how-to-send-json-strings-over-mqtt/46166 "2021-05-24T15:51:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maayz](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@Maayz](https://discourse.nodered.org/u/Maayz)\
**Post date:** [24 May 2021 15:51 UTC](https://discourse.nodered.org/t/how-to-send-json-strings-over-mqtt/46166/1 "2021-05-24T15:51:15Z")

</div>

Hi All,

I have been following this tutorial [Link](http://noderedguide.com/node-red-lecture-3-example-3-2-using-the-switch-node-to-handle-a-json-object/) but i cannot get it to work when i replicate it on my machine.  
I have tried recreating from scratch and also downloaded the flow itself and reconfigured to my MQTT broker but still without joy.

I want to send this via MQTT  
{“analyze”:false, “value”:10}

When i debug from the json node i get this error "Unexpected token “ in JSON at position 1"

When i try to add the switch to the json node and set to msg.payload.analyze to test for True/False i do not get an output from either of them.

I noticed my debug is showing the payload as a string rather than an object, The payload is showed as an object in the lecture article i linked in the debug window. Is this because my message is formatted incorrectly?

Any help is appreciated.

---

<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:** [24 May 2021 15:53 UTC](https://discourse.nodered.org/t/how-to-send-json-strings-over-mqtt/46166/2 "2021-05-24T15:53:01Z")

</div>

> [@Maayz](#):
>
> Unexpected token “ in JSON at position 1

It is literally telling you it doesn't like that non STD quote mark

Replace those smartquotes with normal quotes from your keyboard.

---

<div class="post-metadata">

**Author:** ![Maayz](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@Maayz](https://discourse.nodered.org/u/Maayz)\
**Post date:** [24 May 2021 16:10 UTC](https://discourse.nodered.org/t/how-to-send-json-strings-over-mqtt/46166/3 "2021-05-24T16:10:48Z")

</div>

My mistake, i copied the string from the lecture directly and did not spot that the double quotes were different to usual...

What's the idea behind these being different? " “...

Wasted a few hours working out where id gone wrong on this as well. Cheers for your help.

---

<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 June 2021 16:11 UTC](https://discourse.nodered.org/t/how-to-send-json-strings-over-mqtt/46166/4 "2021-06-07T16:11:31Z")

</div>

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