Moving whole object one level up

Hi, for a simulation I would like to move a JSON output one level up. I found a similar topic in this forum, but I would like to have it the other way around (here). I would like everything in msg.payload to be moved directly to msg. I'm not even sure if this is possible somehow?

Here's my flow:

[{"id":"b14b4779.fc7528","type":"inject","z":"f626dd95.85821","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"topic\":\"0/5/10\",\"payload\":true,\"devicename\":\"Doorbell\",\"payloadmeasureunit\":\"unknown\",\"payloadsubtypevalue\":\"On\",\"knx\":{\"event\":\"GroupValue_Write\",\"dpt\":\"1.001\",\"dptdesc\":\"Switch\",\"source\":\"1.0.10\",\"destination\":\"0/5/10\",\"rawValue\":[1]},\"previouspayload\":\"\"}","payloadType":"str","x":230,"y":1280,"wires":[["1c8ee81f.7b23d8"]]},{"id":"1c8ee81f.7b23d8","type":"json","z":"f626dd95.85821","name":"","property":"payload","action":"","pretty":true,"x":350,"y":1280,"wires":[["1eb0fd67.cb58c3"]]},{"id":"1eb0fd67.cb58c3","type":"debug","z":"f626dd95.85821","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":490,"y":1280,"wires":[]}]

Maybe someone has a simple idea and could help me.

thanks!

[{"id":"b14b4779.fc7528","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"topic\":\"0/5/10\",\"payload\":true,\"devicename\":\"Doorbell\",\"payloadmeasureunit\":\"unknown\",\"payloadsubtypevalue\":\"On\",\"knx\":{\"event\":\"GroupValue_Write\",\"dpt\":\"1.001\",\"dptdesc\":\"Switch\",\"source\":\"1.0.10\",\"destination\":\"0/5/10\",\"rawValue\":[1]},\"previouspayload\":\"\"}","payloadType":"json","x":310,"y":3280,"wires":[["f4dd5962.6e12d8"]]},{"id":"f4dd5962.6e12d8","type":"function","z":"c74669a0.6a34f8","name":"","func":"msg = msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":3280,"wires":[["1eb0fd67.cb58c3"]]},{"id":"1eb0fd67.cb58c3","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":3260,"wires":[]}]

just use a function node and set msg=msg.payload;

thanks, that did the trick. I didn't expect it to be that easy.

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