# MQTT Custom name space Dealing with strings

**URL:** <https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376>\
**Category:** Ignition\
**Created:** [November 2, 2023, 1:06pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376 "2023-11-02T13:06:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephen\_collier](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@stephen\_collier](https://forum.inductiveautomation.com/u/stephen_collier)\
**Post date:** [November 2, 2023, 1:06pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/1 "2023-11-02T13:06:34Z")

</div>

Hi All,

I'm subscribing to a topic that has mutable tags of in two 16bit modbus registers, what is the best may to combine the registers and break the string up into usable tags?  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/7/67d6366183ac33fb80a78cefe1622cd739c1ee4e.png)

 ![MQQTString](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/f/bf816be3517f1ced5585bc086e372cc6e9b29e5a.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 2, 2023, 1:21pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/2 "2023-11-02T13:21:32Z")

</div>

This image is too small to see anything.

---

<div class="post-metadata">

**Author:** ![stephen\_collier](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@stephen\_collier](https://forum.inductiveautomation.com/u/stephen_collier)\
**Post date:** [November 2, 2023, 2:53pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/3 "2023-11-02T14:53:45Z")

</div>

Thanks Kevin, i've uploaded a better image

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [November 2, 2023, 3:30pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/4 "2023-11-02T15:30:05Z")

</div>

It looks like that topic is getting JSON payloads published to it, that might be a good first stop. Have you tried enabling "JSON Payload" in the _Optional_ settings of your Custom namespace in MQTT Engine? That would at least give you a break-out of that `data` array in tags within MQTT Engine.

---

<div class="post-metadata">

**Author:** ![stephen\_collier](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@stephen\_collier](https://forum.inductiveautomation.com/u/stephen_collier)\
**Post date:** [November 2, 2023, 3:35pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/5 "2023-11-02T15:35:20Z")

</div>

Hi Kevin,

Yes i've tried, i don't seem to receive anything when i enable the JSON payload

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 2, 2023, 3:38pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/6 "2023-11-02T15:38:33Z")

</div>

Can you copy paste the whole JSON payload here? Maybe we can inspect it to see if it’s not actually valid JSON. I see literal “\n” in the screenshots which is not a promising start.

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [November 2, 2023, 3:40pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/7 "2023-11-02T15:40:24Z")

</div>

Also, you might have to:

- Delete the existing tag (from the previous configuration) in MQTT Engine.
- Wait for a new message to be published to that topic.
- Inspect the _Status -\> Diagnostics -\> Logs_ page of the Gateway web UI and look for any JSON parsing errors from MQTT Engine (if you don't see the expected result, which should be a folder named `818MFMHive` and tags for each of the keys in the JSON object).

---

<div class="post-metadata">

**Author:** ![stephen\_collier](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@stephen\_collier](https://forum.inductiveautomation.com/u/stephen_collier)\
**Post date:** [November 2, 2023, 3:50pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/8 "2023-11-02T15:50:02Z")

</div>

Hi Kevin,

Its not being sent to the broker in JSON, its a string,

Its sent to the Hive broker as the string below.

{"TS" : "%date%", "Slave name" : "B18\_Hive\_Connection", "data" : "%data%", "Register Request" : "%name%"}

I'm receiving the same string in the ignition engine and MQQT FX as below

{"modbus\_B18\_Hive\_Connection":"{"TS" : "02/11/2023 15:37:31", "Slave name" : "B18\_Hive\_Connection", "data" : "[-5325,17934]", "Register Request" : "ToTkW"}\n\n.{"TS" : "02/11/2023 15:37:32", "Slave name" : "B18\_Hive\_Connection", "data" : "[16384,17257]", "Register Request" : "V1N"}\n\n"}

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 2, 2023, 3:56pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/9 "2023-11-02T15:56:37Z")

</div>

Where does that substitution happen?

It looks like something along the chain is bungling the JSON encoding/decoding and you end up with a string payload resembling JSON but not actually JSON.

---

<div class="post-metadata">

**Author:** ![stephen\_collier](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@stephen\_collier](https://forum.inductiveautomation.com/u/stephen_collier)\
**Post date:** [November 2, 2023, 4:21pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/10 "2023-11-02T16:21:04Z")

</div>

not sure, maybe if it try and format the sent string into a json array it might work.

---

<div class="post-metadata">

**Author:** ![stephen\_collier](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@stephen\_collier](https://forum.inductiveautomation.com/u/stephen_collier)\
**Post date:** [November 3, 2023, 4:28pm UTC](https://forum.inductiveautomation.com/t/mqtt-custom-name-space-dealing-with-strings/81376/11 "2023-11-03T16:28:16Z")

</div>

Thanks All,

I managed to get this sorted, for some reason Ignition engine with the JSON payload enabled kept giving errors when i used double quotes. it worked fine in single quotes. i always taught double quotes was Propper json.  
"Name" : "Value" vs 'Name' : 'Value'
