Is switch the proper node to split and object?

This is a silly question since a split node exist, but I wanna explain what are my goals.

I have an object like:

msg.payload = {
  "speed": {
    "_set": 8.5,
    "_get": 0
  },
  "info": {
    "current": 0,
    "Vdc": 321,
    "state": 0,
    "Vout": 0,
    "torque": 0,
    "Pout": 0,
    "pf": 0
  }
}

I wanna access the values of speed._get and info.current.
I'm using Edit change node to get those values. Is there a way to use switch with two outputs?

image

Put simply no.

Do you actually need those values to be in the msg.payload, if not just access them where they are.
If you do you could send the same msg to two change nodes.

You could combine a split with a switch.
e.g.

[{"id":"17576336cded5386","type":"inject","z":"1d319bc3005a51a2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{   \"speed\": {     \"_set\": 8.5,     \"_get\": 0   },   \"info\": {     \"current\": 0,     \"Vdc\": 321,     \"state\": 0,     \"Vout\": 0,     \"torque\": 0,     \"Pout\": 0,     \"pf\": 0   } }","payloadType":"json","x":90,"y":740,"wires":[["f5ff82e8913a92e0"]]},{"id":"f5ff82e8913a92e0","type":"split","z":"1d319bc3005a51a2","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":210,"y":740,"wires":[["4ae02073b26113f2"]]},{"id":"4ae02073b26113f2","type":"switch","z":"1d319bc3005a51a2","name":"","property":"parts.key","propertyType":"msg","rules":[{"t":"eq","v":"speed","vt":"str"},{"t":"eq","v":"info","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":330,"y":740,"wires":[["5980bfbc3811ca4b"],["c66dee150c0135b4"]]},{"id":"5980bfbc3811ca4b","type":"debug","z":"1d319bc3005a51a2","name":"debug 298","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload._set","statusType":"msg","x":550,"y":700,"wires":[]},{"id":"c66dee150c0135b4","type":"debug","z":"1d319bc3005a51a2","name":"debug 299","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload.current","statusType":"msg","x":550,"y":760,"wires":[]}]

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