# How to convert json text into json object inside the msg object

**URL:** https://discourse.nodered.org/t/how-to-convert-json-text-into-json-object-inside-the-msg-object/100323
**Category:** General
**Tags:** home-assistant, change-node
**Created:** [5 February 2026 23:33 UTC](https://discourse.nodered.org/t/how-to-convert-json-text-into-json-object-inside-the-msg-object/100323 "2026-02-05T23:33:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![CoderN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/codern/32/101562_2.png) [@CoderN](https://discourse.nodered.org/u/CoderN)
#### Post date: [5 February 2026 23:33 UTC](https://discourse.nodered.org/t/how-to-convert-json-text-into-json-object-inside-the-msg-object/100323/1 "2026-02-05T23:33:57Z")

</div>

I have a flow that synchronize the states of 2 instances of _Home Assistants_. The output of sqlite query feeds a sensor node on another Home Assistant. An example output of the msg is like:

```auto
[
  {
    "state": "1",
    "shared_attrs": "{\"entity_ids\":[\"sensor.ds918plus_drive_1_temperature\",\"sensor.ds918plus_drive_2_temperature\"],\"entities\":[\"sensor.ds918plus_drive_1_temperature = 24.0℃\",\"sensor.ds918plus_drive_2_temperature = 23.0℃\"],\"icon\":\"mdi:harddisk-remove\",\"friendly_name\":\"DS918+ Suboptimal Temperature Storage Device Count\"}"
  }
]

```

I would like to insert a json object for the key "entity\_ids" with the value from the "entity\_ids" inside the json string of "shared\_attrs" and remove the "shared\_attrs" key/value pair. I.e.

```auto
[
  {
    "state": "1",
    "entity_ids": [
      "sensor.ds918plus_drive_1_temperature",
      "sensor.ds918plus_drive_2_temperature"
    ]
  }
]

```

How can I do it?

Many thanks in advance.

---

<div class="post-metadata">

### Author: ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)
#### Post date: [5 February 2026 23:51 UTC](https://discourse.nodered.org/t/how-to-convert-json-text-into-json-object-inside-the-msg-object/100323/2 "2026-02-05T23:51:55Z")

</div>

Hi there,

```flows
[{"id":"e7ecd5a8bf104cfa","type":"json","z":"875a27ee3d026455","name":"","property":"payload[0].shared_attrs","action":"","pretty":false,"x":360,"y":271,"wires":[["fef1d63b6149d625"]]},{"id":"880e86e307e18dc9","type":"inject","z":"875a27ee3d026455","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"state\":\"1\",\"shared_attrs\":\"{\\\"entity_ids\\\":[\\\"sensor.ds918plus_drive_1_temperature\\\",\\\"sensor.ds918plus_drive_2_temperature\\\"],\\\"entities\\\":[\\\"sensor.ds918plus_drive_1_temperature = 24.0℃\\\",\\\"sensor.ds918plus_drive_2_temperature = 23.0℃\\\"],\\\"icon\\\":\\\"mdi:harddisk-remove\\\",\\\"friendly_name\\\":\\\"DS918+ Suboptimal Temperature Storage Device Count\\\"}\"}]","payloadType":"json","x":145,"y":215,"wires":[["e7ecd5a8bf104cfa"]]},{"id":"fef1d63b6149d625","type":"debug","z":"875a27ee3d026455","name":"debug 118","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","statusVal":"","statusType":"auto","x":568,"y":295,"wires":[]}]

```

this worked for me, the JSON node is configured as:

 ![Screenshot 2026-02-06 at 10.21.35](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/8/68072cd7f45e0b91c19a756f798b239ea14bd81e.png)

But I didn't reset the `shared_attrs`, the result is not quite what you wanted:

 ![Screenshot 2026-02-06 at 10.23.07](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c7c8e652a30534d6ca33e5b32fccd5d10e2dc1ba.png)

---

<div class="post-metadata">

### Author: ![CoderN](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/codern/32/101562_2.png) [@CoderN](https://discourse.nodered.org/u/CoderN)
#### Post date: [6 February 2026 11:42 UTC](https://discourse.nodered.org/t/how-to-convert-json-text-into-json-object-inside-the-msg-object/100323/3 "2026-02-06T11:42:26Z")

</div>

Thanks a lot bro.

You make my day!

---

<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: [20 February 2026 11:43 UTC](https://discourse.nodered.org/t/how-to-convert-json-text-into-json-object-inside-the-msg-object/100323/4 "2026-02-20T11:43:16Z")

</div>

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