# Converting \*entire\* msg object to JSON

**URL:** <https://discourse.nodered.org/t/converting-entire-msg-object-to-json/5967>\
**Category:** General\
**Created:** [19 December 2018 15:39 UTC](https://discourse.nodered.org/t/converting-entire-msg-object-to-json/5967 "2018-12-19T15:39:35Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![JayDickson](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaydickson/32/90592_2.png) [@JayDickson](https://discourse.nodered.org/u/JayDickson)\
**Post date:** [19 December 2018 17:15 UTC](https://discourse.nodered.org/t/converting-entire-msg-object-to-json/5967/3 "2018-12-19T17:15:00Z")

</div>

Worked beautifully. In case someone stumbles across this, my flow was as follows:

**Outbound:** A function node with

```
var payload = JSON.stringify(msg);
node.send({payload});

```

going into a TCP out node set to connect to a specific port and close connection after each message.

**Inbound:** A TCP In node set to listen on the same specified port and output a single string, which then goes to a function node containing:

```
msg = JSON.parse(msg.payload);
return msg;

```

Many thanks to [TotallyInformation](https://discourse.nodered.org/t/converting-entire-msg-object-to-json/5967/2) for answering in a way that put me on the right path but was just far enough from hand-holding to make me have to bash my head against it to learn a bit.

---

_[View the full topic](https://discourse.nodered.org/t/converting-entire-msg-object-to-json/5967)._
