Modifying object variable name


#1

Hi!
I am having some trouble with this simple task:
I have a msg.payload like this:
"response": "221321312"
And I want to be able to change it for "WhateverIWant":"221321312" .
I have tried with change and switch but I am lost, it would be sweet if you can help me.
Thanks in advance!


#2

Do you mean that:

msg.payload = {'response':'221321312"}

In other words, the payload is an object?

If so:

msg.payload = { 'WhateverIWant': msg.payload.response }

#3

Thanks! I always forget about objects that was my error.
Regards!