Parsing Json message

I am trying to parse out the value of P: in the attached, with no success. I know I should be able to do this with existing nodes split/switch but am unable. I can change the value of P: using the change node and msg.payload.Z[0].MZ.P

Could someone provide some direction?

The following page in the docs will show you how to use the tools of the debug panel to find the right path.

https://nodered.org/docs/user-guide/messages

Then you should be able to use the change node

set msg.payload
to msg.payload.Z[0].MZ.P

That worked with a single item.
If I wanted to use the switch node to output the result of P,V,M,F to different switch outputs, how would this be done. I had read the messages guide and is wsa not clear for my example.
[{"id":"1ed8ef9f.27b5c","type":"inject","z":"d63d935a.2ab68","name":"Status","topic":"","payload":"{"Z":[{"MZ":{"P":0,"V": 90,"M":0,"F": 1}},{"Z2":{"P":0,"V": 51,"M":0,"F": 1}},{"Z3":{"P":0,"V": 59,"M":0,"F": 1}},{"HZ":{"P":0,"V": -1,"M":0,"F": 6}}],"DSP":2,"L":"020d","A":-1,"HOA":1,"LC":"PWR" ,"MA":0,"MS":"0000000","MC":0,"HP":0,"HM":0 ,"DLBES":1,"DLBSR":1,"MN":"SC-85/CUXJ"}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1250,"y":620,"wires":[["48d058a1.0d6368"]]},{"id":"48d058a1.0d6368","type":"json","z":"d63d935a.2ab68","name":"","property":"payload","action":"","pretty":false,"x":1390,"y":620,"wires":[["5d8c0dd9.308fc4","60927d25.07aef4","69460d37.6bf364"]]},{"id":"5d8c0dd9.308fc4","type":"change","z":"d63d935a.2ab68","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"msg.payload.Z[0].MZ.P","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":660,"wires":[["79e16a4f.1932c4"]]},{"id":"ee70ab6f.ba2108","type":"debug","z":"d63d935a.2ab68","name":"parse","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1890,"y":620,"wires":},{"id":"60927d25.07aef4","type":"Input Split","z":"d63d935a.2ab68","name":"","inputProps":["payload.Z[0]"],"outputs":1,"x":1600,"y":620,"wires":[["ee70ab6f.ba2108"]]},{"id":"69460d37.6bf364","type":"switch","z":"d63d935a.2ab68","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"msg.payload.Z[0].MZ.P","vt":"msg"}],"checkall":"true","repair":false,"outputs":1,"x":1590,"y":700,"wires":[["dbf6bbf4.37e4f8"]]},{"id":"dbf6bbf4.37e4f8","type":"debug","z":"d63d935a.2ab68","name":"Split","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1890,"y":700,"wires":},{"id":"79e16a4f.1932c4","type":"debug","z":"d63d935a.2ab68","name":"Change","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1900,"y":660,"wires":}]Preformatted text

I will need to try and attaching the code again

probably easier to do in a function node see https://nodered.org/docs/user-guide/writing-functions#multiple-outputs

[{"id":"1ed8ef9f.27b5c","type":"inject","z":"d63d935a.2ab68","name":"Status","topic":"","payload":"{\"Z\":[{\"MZ\":{\"P\":0,\"V\": 90,\"M\":0,\"F\": 1}},{\"Z2\":{\"P\":0,\"V\": 51,\"M\":0,\"F\": 1}},{\"Z3\":{\"P\":0,\"V\": 59,\"M\":0,\"F\": 1}},{\"HZ\":{\"P\":0,\"V\": -1,\"M\":0,\"F\": 6}}],\"DSP\":2,\"L\":\"020d\",\"A\":-1,\"HOA\":1,\"LC\":\"PWR\" ,\"MA\":0,\"MS\":\"0000000\",\"MC\":0,\"HP\":0,\"HM\":0 ,\"DLBES\":1,\"DLBSR\":1,\"MN\":\"SC-85/CUXJ\"}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1250,"y":620,"wires":[["48d058a1.0d6368"]]},{"id":"48d058a1.0d6368","type":"json","z":"d63d935a.2ab68","name":"","property":"payload","action":"","pretty":false,"x":1390,"y":620,"wires":[["5d8c0dd9.308fc4","60927d25.07aef4","69460d37.6bf364"]]},{"id":"5d8c0dd9.308fc4","type":"change","z":"d63d935a.2ab68","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"msg.payload.Z[0].MZ.P","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1620,"y":660,"wires":[["79e16a4f.1932c4"]]},{"id":"ee70ab6f.ba2108","type":"debug","z":"d63d935a.2ab68","name":"parse","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1890,"y":620,"wires":[]},{"id":"60927d25.07aef4","type":"Input Split","z":"d63d935a.2ab68","name":"","inputProps":["payload.Z[0]"],"outputs":1,"x":1600,"y":620,"wires":[["ee70ab6f.ba2108"]]},{"id":"69460d37.6bf364","type":"switch","z":"d63d935a.2ab68","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"msg.payload.Z[0].MZ.P","vt":"msg"}],"checkall":"true","repair":false,"outputs":1,"x":1590,"y":700,"wires":[["dbf6bbf4.37e4f8"]]},{"id":"dbf6bbf4.37e4f8","type":"debug","z":"d63d935a.2ab68","name":"Split","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1890,"y":700,"wires":[]},{"id":"79e16a4f.1932c4","type":"debug","z":"d63d935a.2ab68","name":"Change","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1900,"y":660,"wires":[]}]

As I said before, probably easier to do in a function node...

@Beothuk the Switch node does not do what you think it does.

The Switch node can be used to route a message to different outputs depending on which rules pass in the node. It does not change the message in anyway.

In your example, you have the Change node configured like this:

This will set the property msg.payload to the value of msg.msg.payload.Z[0].MZ.P. Note you have an extra msg in there because you have put msg. at the start of the field. If you have selected msg. as the type, you do not include msg. in the value field.

Here's an example if fixed Change nodes.

[{"id":"9703b666.e35128","type":"inject","z":"b6cfa8c8.cbc768","name":"Status","topic":"","payload":"{\"Z\":[{\"MZ\":{\"P\":0,\"V\": 90,\"M\":0,\"F\": 1}},{\"Z2\":{\"P\":0,\"V\": 51,\"M\":0,\"F\": 1}},{\"Z3\":{\"P\":0,\"V\": 59,\"M\":0,\"F\": 1}},{\"HZ\":{\"P\":0,\"V\": -1,\"M\":0,\"F\": 6}}],\"DSP\":2,\"L\":\"020d\",\"A\":-1,\"HOA\":1,\"LC\":\"PWR\" ,\"MA\":0,\"MS\":\"0000000\",\"MC\":0,\"HP\":0,\"HM\":0 ,\"DLBES\":1,\"DLBSR\":1,\"MN\":\"SC-85/CUXJ\"}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":300,"wires":[["5e12c61e.e6ed28"]]},{"id":"5e12c61e.e6ed28","type":"json","z":"b6cfa8c8.cbc768","name":"","property":"payload","action":"","pretty":false,"x":330,"y":300,"wires":[["599d42b9.33fcac","7a33fa82.51faf4","faa5e067.6f432","afb6ebfb.47f4b8"]]},{"id":"599d42b9.33fcac","type":"change","z":"b6cfa8c8.cbc768","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Z[0].MZ.P","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":240,"wires":[["7bd73809.f4ef58"]]},{"id":"7a33fa82.51faf4","type":"change","z":"b6cfa8c8.cbc768","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Z[0].MZ.V","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":280,"wires":[["aee5c84b.5baf28"]]},{"id":"faa5e067.6f432","type":"change","z":"b6cfa8c8.cbc768","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Z[0].MZ.M","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":320,"wires":[["a04576eb.4f92b8"]]},{"id":"afb6ebfb.47f4b8","type":"change","z":"b6cfa8c8.cbc768","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Z[0].MZ.F","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":360,"wires":[["8991c70e.d96bd8"]]},{"id":"7bd73809.f4ef58","type":"debug","z":"b6cfa8c8.cbc768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":240,"wires":[]},{"id":"aee5c84b.5baf28","type":"debug","z":"b6cfa8c8.cbc768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":280,"wires":[]},{"id":"a04576eb.4f92b8","type":"debug","z":"b6cfa8c8.cbc768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":320,"wires":[]},{"id":"8991c70e.d96bd8","type":"debug","z":"b6cfa8c8.cbc768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":360,"wires":[]}]

As @ukmoose says, you can also do this with a function node configured with 4 outputs:

return [
   { payload: msg.payload.Z[0].MZ.P },
   { payload: msg.payload.Z[0].MZ.V },
   { payload: msg.payload.Z[0].MZ.M },
   { payload: msg.payload.Z[0].MZ.F }
]

Thanks Very much.
Closed
[{"id":"1ed8ef9f.27b5c","type":"inject","z":"d63d935a.2ab68","name":"Status","topic":"","payload":"{\"Z\":[{\"MZ\":{\"P\":0,\"V\": 90,\"M\":0,\"F\": 1}},{\"Z2\":{\"P\":0,\"V\": 51,\"M\":0,\"F\": 1}},{\"Z3\":{\"P\":0,\"V\": 59,\"M\":0,\"F\": 1}},{\"HZ\":{\"P\":0,\"V\": -1,\"M\":0,\"F\": 6}}],\"DSP\":2,\"L\":\"020d\",\"A\":-1,\"HOA\":1,\"LC\":\"PWR\" ,\"MA\":0,\"MS\":\"0000000\",\"MC\":0,\"HP\":0,\"HM\":0 ,\"DLBES\":1,\"DLBSR\":1,\"MN\":\"SC-85/CUXJ\"}","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1370,"y":560,"wires":[["48d058a1.0d6368"]]},{"id":"15079e9d.0054e1","type":"http request","z":"d63d935a.2ab68","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"http://192.168.1.140/StatusHandler.asp","tls":"","proxy":"","authType":"basic","x":1350,"y":480,"wires":[["48d058a1.0d6368"]]},{"id":"86dcafae.96037","type":"inject","z":"d63d935a.2ab68","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1200,"y":480,"wires":[["15079e9d.0054e1"]]},{"id":"48d058a1.0d6368","type":"json","z":"d63d935a.2ab68","name":"","property":"payload","action":"","pretty":false,"x":1530,"y":560,"wires":[["795f34e9.ff135c"]]},{"id":"795f34e9.ff135c","type":"function","z":"d63d935a.2ab68","name":"Main Zone","func":"var P = { payload: msg.payload.Z[0].MZ.P };\nvar V = { payload: msg.payload.Z[0].MZ.V };\nvar M = { payload: msg.payload.Z[0].MZ.M };\nvar F = { payload: msg.payload.Z[0].MZ.F };\nreturn [ msg, P, V, M, F ];\n","outputs":5,"noerr":0,"x":1690,"y":560,"wires":[["8339dc59.db9a7"],["b5ef34e4.a25548"],["82d4f8c0.8723a8"],["264542bc.67532e"],["6b6979c0.5966e8"]]},{"id":"b5ef34e4.a25548","type":"debug","z":"d63d935a.2ab68","name":"Function_P2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1950,"y":520,"wires":[]},{"id":"82d4f8c0.8723a8","type":"debug","z":"d63d935a.2ab68","name":"Function_P3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1950,"y":560,"wires":[]},{"id":"264542bc.67532e","type":"debug","z":"d63d935a.2ab68","name":"Function_P4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1950,"y":600,"wires":[]},{"id":"6b6979c0.5966e8","type":"debug","z":"d63d935a.2ab68","name":"Function_P5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1950,"y":640,"wires":[]},{"id":"8339dc59.db9a7","type":"debug","z":"d63d935a.2ab68","name":"Msg_P1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1940,"y":480,"wires":[]}]

Thanks

Chris