# Filtering JSON WiFi data

**URL:** https://discourse.nodered.org/t/filtering-json-wifi-data/64064
**Category:** General
**Created:** [17 June 2022 10:45 UTC](https://discourse.nodered.org/t/filtering-json-wifi-data/64064 "2022-06-17T10:45:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Samokomo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/samokomo/32/63918_2.png) [@Samokomo](https://discourse.nodered.org/u/Samokomo)
#### Post date: [17 June 2022 10:45 UTC](https://discourse.nodered.org/t/filtering-json-wifi-data/64064/1 "2022-06-17T10:45:32Z")

</div>

Hello,

I am new to Node-Red and I am struggling to find a way to filter JSON data - lets break it down.  
My WiFi Data looks like:

{"id\_external":"\*3103B","mac":"58:XX:25:XX:52:XX","eap":"","interface":"2.4GHz-XXX11-4np-BD-1-2",  
"ssid":"XXXiot2","uptime":"12s260ms","packets":"172,172","bytes":"11220,40525","tx\_rate":"21.6Mbps-20MHz/1S/SGI",  
"rx\_rate":"13Mbps-20MHz/1S","tx\_rate\_set":"OFDM:6-54 BW:1x SGI:1x HT:0-7"}"

I want to retain only data which contains/equals to list of specific mac adresses.

Even better solution would be similar to this node from pallete: node-red-contrib-filter. This node allows for filtering specific values to separate outputs. But this node is not working for JSON as far as I can tell.

Any suggestions? I found some topics about but it has not worked for me. Thanks!

---

<div class="post-metadata">

### Author: ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)
#### Post date: [17 June 2022 11:11 UTC](https://discourse.nodered.org/t/filtering-json-wifi-data/64064/2 "2022-06-17T11:11:15Z")

</div>

You can do something like this, which will only pass messages where mac is in the list-

```auto
let list = ["58:XX:25:XX:52:XX","XX:XX:XX:XX:XX:XX"]
let index = list.indexOf(msg.payload.mac)

if (index != -1) {
    return msg;
}

```

```auto
[{"id":"4a338a4e4a03e0d0","type":"debug","z":"e881895e805989dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":540,"wires":[]},{"id":"fda42ac906f399c1","type":"function","z":"e881895e805989dc","name":"","func":"let list = [\"58:XX:25:XX:52:XX\",\"XX:XX:XX:XX:XX:XX\"]\nlet index = list.indexOf(msg.payload.mac)\n\nif (index != -1) {\n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":540,"wires":[["4a338a4e4a03e0d0"]]},{"id":"c5fa6e88615664a5","type":"inject","z":"e881895e805989dc","name":"In List","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"id_external\":\"*3103B\",\"mac\":\"58:XX:25:XX:52:XX\",\"eap\":\"\",\"interface\":\"2.4GHz-XXX11-4np-BD-1-2\",\"ssid\":\"XXXiot2\",\"uptime\":\"12s260ms\",\"packets\":\"172,172\",\"bytes\":\"11220,40525\",\"tx_rate\":\"21.6Mbps-20MHz/1S/SGI\",\"rx_rate\":\"13Mbps-20MHz/1S\",\"tx_rate_set\":\"OFDM:6-54 BW:1x SGI:1x HT:0-7\"}","payloadType":"json","x":610,"y":500,"wires":[["fda42ac906f399c1"]]},{"id":"e9bdf8589a2887e1","type":"inject","z":"e881895e805989dc","name":"In List","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"id_external\":\"*3103B\",\"mac\":\"XX:XX:XX:XX:XX:XX\",\"eap\":\"\",\"interface\":\"2.4GHz-XXX11-4np-BD-1-2\",\"ssid\":\"XXXiot2\",\"uptime\":\"12s260ms\",\"packets\":\"172,172\",\"bytes\":\"11220,40525\",\"tx_rate\":\"21.6Mbps-20MHz/1S/SGI\",\"rx_rate\":\"13Mbps-20MHz/1S\",\"tx_rate_set\":\"OFDM:6-54 BW:1x SGI:1x HT:0-7\"}","payloadType":"json","x":610,"y":560,"wires":[["fda42ac906f399c1"]]},{"id":"77abe898e8132cee","type":"inject","z":"e881895e805989dc","name":"Not In List","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"id_external\":\"*3103B\",\"mac\":\"YY:XX:XX:XX:XX:XX\",\"eap\":\"\",\"interface\":\"2.4GHz-XXX11-4np-BD-1-2\",\"ssid\":\"XXXiot2\",\"uptime\":\"12s260ms\",\"packets\":\"172,172\",\"bytes\":\"11220,40525\",\"tx_rate\":\"21.6Mbps-20MHz/1S/SGI\",\"rx_rate\":\"13Mbps-20MHz/1S\",\"tx_rate_set\":\"OFDM:6-54 BW:1x SGI:1x HT:0-7\"}","payloadType":"json","x":620,"y":620,"wires":[["fda42ac906f399c1"]]}]

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [16 August 2022 11:12 UTC](https://discourse.nodered.org/t/filtering-json-wifi-data/64064/3 "2022-08-16T11:12:09Z")

</div>

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