# Un-deprecate "string or buffer" autodetection in mqtt-in node

**URL:** <https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897>\
**Category:** Feature Requests\
**Created:** [29 August 2023 23:48 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897 "2023-08-29T23:48:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndreKR](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrekr/32/81657_2.png) [@AndreKR](https://discourse.nodered.org/u/AndreKR)\
**Post date:** [29 August 2023 23:48 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897/1 "2023-08-29T23:48:19Z")

</div>

In [MQTT in node auto-detect mode should include trying to parse JSON · Issue #3410 · node-red/node-red · GitHub](https://github.com/node-red/node-red/issues/3410) (by @dceejay and @knolleary) the ability to auto-detect and parse JSON in an MQTT message was added. At the same time the old auto-detect logic "string or buffer" was deprecated.

I have a flow that just stores MQTT messages in a log without looking at their contents at all.

I could set the output to "a Buffer" and it would work. However, this also makes the message hard to read in debug nodes, so the "string and buffer" mode is perfect for this. Strings can be stored in the log just like buffers.

The "parsed JSON object, string or buffer" mode adds additional complication: I have to re-stringify the messages before I can put them in the log.

Can we un-deprecate the "string or buffer" mode?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 August 2023 08:07 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897/2 "2023-08-30T08:07:36Z")

</div>

It may have been deprecated - but wasn't removed...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/4390a310bf384ea517d2dbbb61cb739c80bcf4ee.png)

---

<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:** [30 August 2023 08:43 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897/3 "2023-08-30T08:43:11Z")

</div>

> [@AndreKR](#):
>
> The "parsed JSON object, string or buffer" mode adds additional complication: I have to re-stringify the messages before I can put them in the log.

what are you using to log?

There are smarter nodes for logging objects - for example [`node-red-contrib-flogger`](https://flows.nodered.org/node/node-red-contrib-flogger)

---

<div class="post-metadata">

**Author:** ![AndreKR](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrekr/32/81657_2.png) [@AndreKR](https://discourse.nodered.org/u/AndreKR)\
**Post date:** [30 August 2023 09:14 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897/4 "2023-08-30T09:14:18Z")

</div>

> [@dceejay](#):
>
> It may have been deprecated - but wasn't removed...

I know, I'm using it very successfully, hence the feature request to un-deprecate it. It is very useful so it would be great if it would continue to work in a future version of Node-RED.

> [@Steve-Mcl](#):
>
> what are you using to log?

Sending it off to Loki with an _http request_ node.

---

<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:** [30 August 2023 09:18 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897/5 "2023-08-30T09:18:18Z")

</div>

> [@AndreKR](#):
>
> Sending it off to Loki with an _http request_ node.

not sure why you have to stringify the object then. I am almost certain the HTTP Request node stringifies the payload automatically?

---

<div class="post-metadata">

**Author:** ![AndreKR](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrekr/32/81657_2.png) [@AndreKR](https://discourse.nodered.org/u/AndreKR)\
**Post date:** [30 August 2023 09:22 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897/6 "2023-08-30T09:22:20Z")

</div>

I'm putting it into another object together with metadata about the MQTT message: `{topic: ..., qos: ..., retain: ..., payload: ...}`.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 August 2023 13:08 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897/7 "2023-08-30T13:08:52Z")

</div>

> [@AndreKR](#):
>
> hence the feature request to un-deprecate it.

Must admit I'm not aware of any current intention to remove this (@Steve-Mcl ?) - so yes I have no objection to leaving it there and removing the comment instead.

---

<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:** [30 August 2023 13:51 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897/8 "2023-08-30T13:51:11Z")

</div>

> [@dceejay](#):
>
> Must admit I'm not aware of any current intention to remove this

It was my hope to remove it in the next major release

Re: depreciated: [MQTT payload auto parsing improvements by Steve-Mcl · Pull Request #3530 · node-red/node-red · GitHub](https://github.com/node-red/node-red/pull/3530#issuecomment-1105730063)

But the OP has highlighted a use case, I may leave it for a later major release (or never 🤷‍♂️ )

NOTE: However, if the OP wishes for me to remember I said that ↑ an issue should be raised so it is not forgotten 😃

---

<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:** [29 October 2023 13:52 UTC](https://discourse.nodered.org/t/un-deprecate-string-or-buffer-autodetection-in-mqtt-in-node/80897/9 "2023-10-29T13:52:01Z")

</div>

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