Help with incoming tranformation

i strangle to fetch a mqtt state of the switch /outlet 0 .The topic publish :

{"NSPanel":{"ctype":"group","id":"2","params":{"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]}}}

so i use regex to filter

REGEX:(.*"id":"2".*)

and then i try several vercions of JSONPATH like

JSONPATH:$.NSPanel.params.switches.switch

but it doesnt work and i am complete newbie at this and dont know what to try.Can anyone has an idea where to start?

JSONPATH:$.NSPanel.params.switches[0].switch

1 Like

You could get away with the simple index, but it’s better to be precise:

JSONPATH:$.NSPanel.params.switches[?(@.outlet=='0')].switch

This is: Search for a node, which contains a field “outlet” with the value “0”. get the value of field “switch” from this node

1 Like