Jsonpath

Hello everyone, I need your help:

I need to read this string JSONPATH {“NSPanel”:{“ctype”:“group”,“id”:“2”,“params”:{“switches”:[{“switch”:“off”,“outlet”: 0},{“switch”:“off”,“outlet”:1}]}}}

the values ​​to read are id,switch and outlet commands of my nspannel widgets which must have the values ​​2,off,0 for off status and 2,on,0 for on status but I can’t set them.

so I ask for your help

ECMAScript 262 Edition 5.1 json.parse.

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
var test = JSON.parse('{"NSPanel":{"ctype":"group","id":"2","params":{"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1}]}}}'); 
logger.info("id: " + test.NSPanel.id)
logger.info("switch: " + test.NSPanel.params.switches[0].switch)
logger.info("outlet: " + test.NSPanel.params.switches[0].outlet)
logger.info("switch: " + test.NSPanel.params.switches[1].switch)
logger.info("outlet: " + test.NSPanel.params.switches[1].outlet)

Which gives output of:

[2023-01-24 20:51:27.297 [INFO ] [org.openhab.rule.50ccdb9783        ] - id: 2
2023-01-24 20:51:27.298 [INFO ] [org.openhab.rule.50ccdb9783         ] - switch: off
2023-01-24 20:51:27.298 [INFO ] [org.openhab.rule.50ccdb9783         ] - outlet: 0
2023-01-24 20:51:27.299 [INFO ] [org.openhab.rule.50ccdb9783         ] - switch: off
2023-01-24 20:51:27.300 [INFO ] [org.openhab.rule.50ccdb9783         ] - outlet: 1

can you send a tutorial on how to set it up? thank you