# Rename key based on a value

**URL:** <https://discourse.nodered.org/t/rename-key-based-on-a-value/10724>\
**Category:** General\
**Created:** [1 May 2019 20:05 UTC](https://discourse.nodered.org/t/rename-key-based-on-a-value/10724 "2019-05-01T20:05:23Z")\
**Posts on this page:** 3\
**Page:** 1

<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:** [1 May 2019 20:05 UTC](https://discourse.nodered.org/t/rename-key-based-on-a-value/10724/1 "2019-05-01T20:05:23Z")

</div>

I'm probably missing something simple, but it's driving me crazy so I figure I'd ask in here. I want to change the key of an object property to match a value of a property contained within it. Can anyone recommend a track to start investigating?

Example:

 ![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/219ae64bcbf78479049a27bd2ce8e72eaf64c11d.jpeg)

I would like the object currently existing as OBX.4 to be OBX.1 (based on OBX.4.setID).

Challenge I'm facing: The messages I'm parsing very greatly in how many OBX rows are present.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [1 May 2019 20:14 UTC](https://discourse.nodered.org/t/rename-key-based-on-a-value/10724/2 "2019-05-01T20:14:03Z")

</div>

You cannot change the key name AFAIK. But you can add a new key.

```auto
OBX[OBX.4.setID] = OBX.4

```

Or something like that, sorry, not tried that code. You could then delete OBX.4

---

<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:** [2 May 2019 18:30 UTC](https://discourse.nodered.org/t/rename-key-based-on-a-value/10724/3 "2019-05-02T18:30:01Z")

</div>

I ended up pulling it off by copying the setID field to its own object, passing to a split node, then using a join node to join to a key value pair using the new setID object as the key. Oddly, I was getting extra payloadless messages even though the split node should (to my understanding) only care about msg.payload. I got around this (possible bug?) by using a pair of JSON nodes to "clean" my msg.payload.
