# Convert MQTT payload

**URL:** <https://discourse.nodered.org/t/convert-mqtt-payload/47895>\
**Category:** General\
**Created:** [1 July 2021 13:31 UTC](https://discourse.nodered.org/t/convert-mqtt-payload/47895 "2021-07-01T13:31:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [1 July 2021 13:31 UTC](https://discourse.nodered.org/t/convert-mqtt-payload/47895/1 "2021-07-01T13:31:55Z")

</div>

From TTN MQTT I read the output of a Dragino LDS02 door/window contact. If I understand correctly that is called a string output (image), am I correct? To process it further I want to split that, I think this is called an object.

I don't know how to convert such a string into an object, does anyone have a tip?

 ![debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/5/f520108788c35acc50bd7c4507e1e4ea16ab8c04.png)

---

<div class="post-metadata">

**Author:** ![MyRandomThoughts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myrandomthoughts/32/41085_2.png) [@MyRandomThoughts](https://discourse.nodered.org/u/MyRandomThoughts)\
**Post date:** [1 July 2021 13:36 UTC](https://discourse.nodered.org/t/convert-mqtt-payload/47895/2 "2021-07-01T13:36:32Z")

</div>

Have you tried using the JSON node in the "parser" group. It converts between a JSON string and its JavaScript object representation, in either direction.

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [1 July 2021 13:43 UTC](https://discourse.nodered.org/t/convert-mqtt-payload/47895/3 "2021-07-01T13:43:07Z")

</div>

If you, like me, are alone in front of the computer, you sometimes keep going round in circles without finding the answer. Even if the solution is simple, I would not have found it so quickly.

I'm glad I could consult this forum and get help so quickly. Thanks for helping!

---

<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:** [1 July 2021 15:06 UTC](https://discourse.nodered.org/t/convert-mqtt-payload/47895/4 "2021-07-01T15:06:13Z")

</div>

Even better is to select Parsed JSON output in the mqtt node then it will parse the JSON for you.

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [2 July 2021 06:35 UTC](https://discourse.nodered.org/t/convert-mqtt-payload/47895/5 "2021-07-02T06:35:46Z")

</div>

Thanks Colin.

---

<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:** [16 July 2021 06:36 UTC](https://discourse.nodered.org/t/convert-mqtt-payload/47895/6 "2021-07-16T06:36:27Z")

</div>

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