Extract data from a json object

Hi,

I am trying to extract some nodes from a JSON payload but the JSON structure is not defined in a proper array, and because of that I cannot use functions like find or keys.

I have made a screenshot of the structure. basically it contains one object that contains multiple objects inside. these are not represented using an array. .
I am trying to grab all nodes that contains a property "name" with the value "Samsung"

do you have any sugestions on how to select all objects like so?

thanks in advance,
Norberto

Screenshot 2022-06-26 at 16.45.55

If you hover over the payload & click the "Copy Value" then paste that into a reply between backticks

```
like this
```

I will show you how.

(difficult to work with pictures in code :stuck_out_tongue: )

Sample data

{
    "get_clientlist": {
        "DD:50:E3:54:17:37": {
            "type": "0",
            "defaultType": "0",
            "name": "iot-sfp-tvsala",
            "nickName": "sfp-tvsala",
            "ip": "192.168.2.71",
            "mac": "DD:50:E3:54:17:37",
            "from": "networkmapd",
            "macRepeat": "1",
            "isGateway": "0",
            "isWebServer": "0",
            "isPrinter": "0",
            "isITunes": "0",
            "dpiType": "",
            "dpiDevice": "",
            "vendor": "",
            "isWL": "1",
            "isOnline": "1",
            "ssid": "",
            "isLogin": "0",
            "opMode": "0",
            "rssi": "-68",
            "curTx": "65M",
            "curRx": "48M",
            "totalTx": "",
            "totalRx": "",
            "wlConnectTime": "06:02:18",
            "ipMethod": "Manual",
            "group": "",
            "callback": "",
            "keeparp": "",
            "qosLevel": "",
            "wtfast": "0",
            "internetMode": "allow",
            "internetState": "1"
        },
        "5C:CF:7F:97:48:FF": {
            "type": "0",
            "defaultType": "0",
            "name": "iot-sfb-dog-light",
            "nickName": "sfb-northpoollights",
            "ip": "192.168.2.138",
            "mac": "5C:CF:7F:97:48:FF",
            "from": "networkmapd",
            "macRepeat": "1",
            "isGateway": "0",
            "isWebServer": "0",
            "isPrinter": "0",
            "isITunes": "0",
            "dpiType": "",
            "dpiDevice": "",
            "vendor": "Espressif Inc.",
            "isWL": "1",
            "isOnline": "1",
            "ssid": "",
            "isLogin": "0",
            "opMode": "0",
            "rssi": "-78",
            "curTx": "43M",
            "curRx": "36M",
            "totalTx": "",
            "totalRx": "",
            "wlConnectTime": "06:02:09",
            "ipMethod": "DHCP",
            "group": "",
            "callback": "",
            "keeparp": "",
            "qosLevel": "",
            "wtfast": "0",
            "internetMode": "block",
            "internetState": 0
        },
        "44:17:93:7B:F4:91": {
            "type": "0",
            "defaultType": "0",
            "name": "Samsung",
            "nickName": "iot-snp-panel-gate",
            "ip": "192.168.2.148",
            "mac": "44:17:93:7B:F4:91",
            "from": "networkmapd",
            "macRepeat": "1",
            "isGateway": "0",
            "isWebServer": "0",
            "isPrinter": "0",
            "isITunes": "0",
            "dpiType": "",
            "dpiDevice": "",
            "vendor": "",
            "isWL": "1",
            "isOnline": "1",
            "ssid": "",
            "isLogin": "0",
            "opMode": "0",
            "rssi": "-45",
            "curTx": "72M",
            "curRx": "65M",
            "totalTx": "",
            "totalRx": "",
            "wlConnectTime": "06:02:14",
            "ipMethod": "DHCP",
            "group": "",
            "callback": "",
            "keeparp": "",
            "qosLevel": "",
            "wtfast": "0",
            "internetMode": "allow",
            "internetState": "1"
        },
        "46:AE:00:24:40:8B": {
            "type": "0",
            "defaultType": "0",
            "name": "Samsung",
            "nickName": "",
            "ip": "192.168.2.242",
            "mac": "46:AE:00:24:40:8B",
            "from": "networkmapd",
            "macRepeat": "1",
            "isGateway": "0",
            "isWebServer": "0",
            "isPrinter": "0",
            "isITunes": "0",
            "dpiType": "",
            "dpiDevice": "",
            "vendor": "",
            "isWL": "1",
            "isOnline": "1",
            "ssid": "",
            "isLogin": "0",
            "opMode": "0",
            "rssi": "-60",
            "curTx": "72M",
            "curRx": "72M",
            "totalTx": "",
            "totalRx": "",
            "wlConnectTime": "00:00:39",
            "ipMethod": "DHCP",
            "group": "",
            "callback": "",
            "keeparp": "",
            "qosLevel": "",
            "wtfast": "0",
            "internetMode": "block",
            "internetState": 0
        },
        "maclist": [
            "DD:50:E3:54:17:37",
            "5C:CF:7F:97:48:FF",
            "44:17:93:7B:F4:91",
            "46:AE:00:24:40:8B"
        ]
    }
}

Here is 2 ways (v1: low code v2: just code)

[{"id":"48d660b3a4109400","type":"inject","z":"ffac38bbca9696f3","name":"inject","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":430,"y":480,"wires":[["ba4eb77ee238b17f"]]},{"id":"ecaaf26326da10ee","type":"comment","z":"ffac38bbca9696f3","name":"low-code way","info":"","x":870,"y":440,"wires":[]},{"id":"ba4eb77ee238b17f","type":"function","z":"ffac38bbca9696f3","name":"get_clientlist (faked)","func":"\nmsg.payload = {\n    get_clientlist: {\n    \"AB:CD:EF:00:00:23\": { type: \"23\", defaultType: \"0\", name: \"Samsung\" },\n    \"AB:CD:EF:00:00:24\": { type: \"24\", defaultType: \"0\", name: \"Zamsung\" },\n    \"AB:CD:EF:00:00:25\": { type: \"25\", defaultType: \"0\", name: \"Semseng\" },\n    \"AB:CD:EF:00:00:33\": { type: \"33\", defaultType: \"0\", name: \"Samsung\" },\n    \"AB:CD:EF:00:00:14\": { type: \"14\", defaultType: \"0\", name: \"LG\" },\n    \"AB:CD:EF:00:00:55\": { type: \"55\", defaultType: \"0\", name: \"Zanussi\" },\n    \"AB:CD:EF:00:00:43\": { type: \"43\", defaultType: \"0\", name: \"Samsung\" },\n    \"AB:CD:EF:00:00:99\": { type: \"99\", defaultType: \"0\", name: \"Fredsung\" },\n    }\n}\n\nmsg.payload = {\n    \"get_clientlist\": {\n        \"DD:50:E3:54:17:37\": {\n            \"type\": \"0\",\n            \"defaultType\": \"0\",\n            \"name\": \"iot-sfp-tvsala\",\n            \"nickName\": \"sfp-tvsala\",\n            \"ip\": \"192.168.2.71\",\n            \"mac\": \"DD:50:E3:54:17:37\",\n            \"from\": \"networkmapd\",\n            \"macRepeat\": \"1\",\n            \"isGateway\": \"0\",\n            \"isWebServer\": \"0\",\n            \"isPrinter\": \"0\",\n            \"isITunes\": \"0\",\n            \"dpiType\": \"\",\n            \"dpiDevice\": \"\",\n            \"vendor\": \"\",\n            \"isWL\": \"1\",\n            \"isOnline\": \"1\",\n            \"ssid\": \"\",\n            \"isLogin\": \"0\",\n            \"opMode\": \"0\",\n            \"rssi\": \"-68\",\n            \"curTx\": \"65M\",\n            \"curRx\": \"48M\",\n            \"totalTx\": \"\",\n            \"totalRx\": \"\",\n            \"wlConnectTime\": \"06:02:18\",\n            \"ipMethod\": \"Manual\",\n            \"group\": \"\",\n            \"callback\": \"\",\n            \"keeparp\": \"\",\n            \"qosLevel\": \"\",\n            \"wtfast\": \"0\",\n            \"internetMode\": \"allow\",\n            \"internetState\": \"1\"\n        },\n        \"5C:CF:7F:97:48:FF\": {\n            \"type\": \"0\",\n            \"defaultType\": \"0\",\n            \"name\": \"iot-sfb-dog-light\",\n            \"nickName\": \"sfb-northpoollights\",\n            \"ip\": \"192.168.2.138\",\n            \"mac\": \"5C:CF:7F:97:48:FF\",\n            \"from\": \"networkmapd\",\n            \"macRepeat\": \"1\",\n            \"isGateway\": \"0\",\n            \"isWebServer\": \"0\",\n            \"isPrinter\": \"0\",\n            \"isITunes\": \"0\",\n            \"dpiType\": \"\",\n            \"dpiDevice\": \"\",\n            \"vendor\": \"Espressif Inc.\",\n            \"isWL\": \"1\",\n            \"isOnline\": \"1\",\n            \"ssid\": \"\",\n            \"isLogin\": \"0\",\n            \"opMode\": \"0\",\n            \"rssi\": \"-78\",\n            \"curTx\": \"43M\",\n            \"curRx\": \"36M\",\n            \"totalTx\": \"\",\n            \"totalRx\": \"\",\n            \"wlConnectTime\": \"06:02:09\",\n            \"ipMethod\": \"DHCP\",\n            \"group\": \"\",\n            \"callback\": \"\",\n            \"keeparp\": \"\",\n            \"qosLevel\": \"\",\n            \"wtfast\": \"0\",\n            \"internetMode\": \"block\",\n            \"internetState\": 0\n        },\n        \"44:17:93:7B:F4:91\": {\n            \"type\": \"0\",\n            \"defaultType\": \"0\",\n            \"name\": \"Samsung\",\n            \"nickName\": \"iot-snp-panel-gate\",\n            \"ip\": \"192.168.2.148\",\n            \"mac\": \"44:17:93:7B:F4:91\",\n            \"from\": \"networkmapd\",\n            \"macRepeat\": \"1\",\n            \"isGateway\": \"0\",\n            \"isWebServer\": \"0\",\n            \"isPrinter\": \"0\",\n            \"isITunes\": \"0\",\n            \"dpiType\": \"\",\n            \"dpiDevice\": \"\",\n            \"vendor\": \"\",\n            \"isWL\": \"1\",\n            \"isOnline\": \"1\",\n            \"ssid\": \"\",\n            \"isLogin\": \"0\",\n            \"opMode\": \"0\",\n            \"rssi\": \"-45\",\n            \"curTx\": \"72M\",\n            \"curRx\": \"65M\",\n            \"totalTx\": \"\",\n            \"totalRx\": \"\",\n            \"wlConnectTime\": \"06:02:14\",\n            \"ipMethod\": \"DHCP\",\n            \"group\": \"\",\n            \"callback\": \"\",\n            \"keeparp\": \"\",\n            \"qosLevel\": \"\",\n            \"wtfast\": \"0\",\n            \"internetMode\": \"allow\",\n            \"internetState\": \"1\"\n        },\n        \"46:AE:00:24:40:8B\": {\n            \"type\": \"0\",\n            \"defaultType\": \"0\",\n            \"name\": \"Samsung\",\n            \"nickName\": \"\",\n            \"ip\": \"192.168.2.242\",\n            \"mac\": \"46:AE:00:24:40:8B\",\n            \"from\": \"networkmapd\",\n            \"macRepeat\": \"1\",\n            \"isGateway\": \"0\",\n            \"isWebServer\": \"0\",\n            \"isPrinter\": \"0\",\n            \"isITunes\": \"0\",\n            \"dpiType\": \"\",\n            \"dpiDevice\": \"\",\n            \"vendor\": \"\",\n            \"isWL\": \"1\",\n            \"isOnline\": \"1\",\n            \"ssid\": \"\",\n            \"isLogin\": \"0\",\n            \"opMode\": \"0\",\n            \"rssi\": \"-60\",\n            \"curTx\": \"72M\",\n            \"curRx\": \"72M\",\n            \"totalTx\": \"\",\n            \"totalRx\": \"\",\n            \"wlConnectTime\": \"00:00:39\",\n            \"ipMethod\": \"DHCP\",\n            \"group\": \"\",\n            \"callback\": \"\",\n            \"keeparp\": \"\",\n            \"qosLevel\": \"\",\n            \"wtfast\": \"0\",\n            \"internetMode\": \"block\",\n            \"internetState\": 0\n        },\n        \"maclist\": [\n            \"DD:50:E3:54:17:37\",\n            \"5C:CF:7F:97:48:FF\",\n            \"44:17:93:7B:F4:91\",\n            \"46:AE:00:24:40:8B\"\n        ]\n    }\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":480,"wires":[["366f8480e7be6149"]]},{"id":"6b06e9201712260d","type":"split","z":"ffac38bbca9696f3","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"mac","x":1050,"y":480,"wires":[["50cf798c8bba7d8e"]]},{"id":"366f8480e7be6149","type":"change","z":"ffac38bbca9696f3","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.get_clientlist","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":480,"wires":[["6b06e9201712260d"]]},{"id":"50cf798c8bba7d8e","type":"change","z":"ffac38bbca9696f3","name":"","rules":[{"t":"set","p":"payload.mac","pt":"msg","to":"mac","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1240,"y":480,"wires":[["c88f70e598b5f07a"]]},{"id":"fab52946b034e229","type":"join","z":"ffac38bbca9696f3","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"0.5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1190,"y":540,"wires":[["2db662a8f7e61b22"]]},{"id":"2db662a8f7e61b22","type":"debug","z":"ffac38bbca9696f3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1410,"y":540,"wires":[]},{"id":"c4e9ca5675a239e5","type":"inject","z":"ffac38bbca9696f3","name":"inject","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":430,"y":680,"wires":[["be08e26b9f8b3cfb"]]},{"id":"caae4d3d7090dc93","type":"comment","z":"ffac38bbca9696f3","name":"more-code way","info":"","x":880,"y":640,"wires":[]},{"id":"be08e26b9f8b3cfb","type":"function","z":"ffac38bbca9696f3","name":"get_clientlist (faked)","func":"\nmsg.payload = {\n    get_clientlist: {\n    \"AB:CD:EF:00:00:23\": { type: \"23\", defaultType: \"0\", name: \"Samsung\" },\n    \"AB:CD:EF:00:00:24\": { type: \"24\", defaultType: \"0\", name: \"Zamsung\" },\n    \"AB:CD:EF:00:00:25\": { type: \"25\", defaultType: \"0\", name: \"Semseng\" },\n    \"AB:CD:EF:00:00:33\": { type: \"33\", defaultType: \"0\", name: \"Samsung\" },\n    \"AB:CD:EF:00:00:14\": { type: \"14\", defaultType: \"0\", name: \"LG\" },\n    \"AB:CD:EF:00:00:55\": { type: \"55\", defaultType: \"0\", name: \"Zanussi\" },\n    \"AB:CD:EF:00:00:43\": { type: \"43\", defaultType: \"0\", name: \"Samsung\" },\n    \"AB:CD:EF:00:00:99\": { type: \"99\", defaultType: \"0\", name: \"Fredsung\" },\n    }\n}\n\nmsg.payload = {\n    \"get_clientlist\": {\n        \"DD:50:E3:54:17:37\": {\n            \"type\": \"0\",\n            \"defaultType\": \"0\",\n            \"name\": \"iot-sfp-tvsala\",\n            \"nickName\": \"sfp-tvsala\",\n            \"ip\": \"192.168.2.71\",\n            \"mac\": \"DD:50:E3:54:17:37\",\n            \"from\": \"networkmapd\",\n            \"macRepeat\": \"1\",\n            \"isGateway\": \"0\",\n            \"isWebServer\": \"0\",\n            \"isPrinter\": \"0\",\n            \"isITunes\": \"0\",\n            \"dpiType\": \"\",\n            \"dpiDevice\": \"\",\n            \"vendor\": \"\",\n            \"isWL\": \"1\",\n            \"isOnline\": \"1\",\n            \"ssid\": \"\",\n            \"isLogin\": \"0\",\n            \"opMode\": \"0\",\n            \"rssi\": \"-68\",\n            \"curTx\": \"65M\",\n            \"curRx\": \"48M\",\n            \"totalTx\": \"\",\n            \"totalRx\": \"\",\n            \"wlConnectTime\": \"06:02:18\",\n            \"ipMethod\": \"Manual\",\n            \"group\": \"\",\n            \"callback\": \"\",\n            \"keeparp\": \"\",\n            \"qosLevel\": \"\",\n            \"wtfast\": \"0\",\n            \"internetMode\": \"allow\",\n            \"internetState\": \"1\"\n        },\n        \"5C:CF:7F:97:48:FF\": {\n            \"type\": \"0\",\n            \"defaultType\": \"0\",\n            \"name\": \"iot-sfb-dog-light\",\n            \"nickName\": \"sfb-northpoollights\",\n            \"ip\": \"192.168.2.138\",\n            \"mac\": \"5C:CF:7F:97:48:FF\",\n            \"from\": \"networkmapd\",\n            \"macRepeat\": \"1\",\n            \"isGateway\": \"0\",\n            \"isWebServer\": \"0\",\n            \"isPrinter\": \"0\",\n            \"isITunes\": \"0\",\n            \"dpiType\": \"\",\n            \"dpiDevice\": \"\",\n            \"vendor\": \"Espressif Inc.\",\n            \"isWL\": \"1\",\n            \"isOnline\": \"1\",\n            \"ssid\": \"\",\n            \"isLogin\": \"0\",\n            \"opMode\": \"0\",\n            \"rssi\": \"-78\",\n            \"curTx\": \"43M\",\n            \"curRx\": \"36M\",\n            \"totalTx\": \"\",\n            \"totalRx\": \"\",\n            \"wlConnectTime\": \"06:02:09\",\n            \"ipMethod\": \"DHCP\",\n            \"group\": \"\",\n            \"callback\": \"\",\n            \"keeparp\": \"\",\n            \"qosLevel\": \"\",\n            \"wtfast\": \"0\",\n            \"internetMode\": \"block\",\n            \"internetState\": 0\n        },\n        \"44:17:93:7B:F4:91\": {\n            \"type\": \"0\",\n            \"defaultType\": \"0\",\n            \"name\": \"Samsung\",\n            \"nickName\": \"iot-snp-panel-gate\",\n            \"ip\": \"192.168.2.148\",\n            \"mac\": \"44:17:93:7B:F4:91\",\n            \"from\": \"networkmapd\",\n            \"macRepeat\": \"1\",\n            \"isGateway\": \"0\",\n            \"isWebServer\": \"0\",\n            \"isPrinter\": \"0\",\n            \"isITunes\": \"0\",\n            \"dpiType\": \"\",\n            \"dpiDevice\": \"\",\n            \"vendor\": \"\",\n            \"isWL\": \"1\",\n            \"isOnline\": \"1\",\n            \"ssid\": \"\",\n            \"isLogin\": \"0\",\n            \"opMode\": \"0\",\n            \"rssi\": \"-45\",\n            \"curTx\": \"72M\",\n            \"curRx\": \"65M\",\n            \"totalTx\": \"\",\n            \"totalRx\": \"\",\n            \"wlConnectTime\": \"06:02:14\",\n            \"ipMethod\": \"DHCP\",\n            \"group\": \"\",\n            \"callback\": \"\",\n            \"keeparp\": \"\",\n            \"qosLevel\": \"\",\n            \"wtfast\": \"0\",\n            \"internetMode\": \"allow\",\n            \"internetState\": \"1\"\n        },\n        \"46:AE:00:24:40:8B\": {\n            \"type\": \"0\",\n            \"defaultType\": \"0\",\n            \"name\": \"Samsung\",\n            \"nickName\": \"\",\n            \"ip\": \"192.168.2.242\",\n            \"mac\": \"46:AE:00:24:40:8B\",\n            \"from\": \"networkmapd\",\n            \"macRepeat\": \"1\",\n            \"isGateway\": \"0\",\n            \"isWebServer\": \"0\",\n            \"isPrinter\": \"0\",\n            \"isITunes\": \"0\",\n            \"dpiType\": \"\",\n            \"dpiDevice\": \"\",\n            \"vendor\": \"\",\n            \"isWL\": \"1\",\n            \"isOnline\": \"1\",\n            \"ssid\": \"\",\n            \"isLogin\": \"0\",\n            \"opMode\": \"0\",\n            \"rssi\": \"-60\",\n            \"curTx\": \"72M\",\n            \"curRx\": \"72M\",\n            \"totalTx\": \"\",\n            \"totalRx\": \"\",\n            \"wlConnectTime\": \"00:00:39\",\n            \"ipMethod\": \"DHCP\",\n            \"group\": \"\",\n            \"callback\": \"\",\n            \"keeparp\": \"\",\n            \"qosLevel\": \"\",\n            \"wtfast\": \"0\",\n            \"internetMode\": \"block\",\n            \"internetState\": 0\n        },\n        \"maclist\": [\n            \"DD:50:E3:54:17:37\",\n            \"5C:CF:7F:97:48:FF\",\n            \"44:17:93:7B:F4:91\",\n            \"46:AE:00:24:40:8B\"\n        ]\n    }\n}\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":680,"wires":[["adb93ab9ad7aed15"]]},{"id":"bf5eee97271ad732","type":"debug","z":"ffac38bbca9696f3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1410,"y":680,"wires":[]},{"id":"adb93ab9ad7aed15","type":"function","z":"ffac38bbca9696f3","name":"samsung only","func":"const data = Object.entries(msg.payload.get_clientlist).map(e=>{return { ...e[1], mac: e[0] } })\n\nmsg.payload = data.filter(e => e.name && e.name.toLowerCase() === \"samsung\")\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":680,"wires":[["bf5eee97271ad732"]]},{"id":"c88f70e598b5f07a","type":"switch","z":"ffac38bbca9696f3","name":"","property":"$lowercase(payload.name)\t","propertyType":"jsonata","rules":[{"t":"eq","v":"samsung","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1050,"y":540,"wires":[["fab52946b034e229"]]}]

Was looking for the "just code" version. Works perfectly!!

Thanks Steve.

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