# Using JSONata to filter out one phone number from a Fritzbox phone book

**URL:** <https://discourse.nodered.org/t/using-jsonata-to-filter-out-one-phone-number-from-a-fritzbox-phone-book/68493>\
**Category:** General\
**Created:** [2 October 2022 17:40 UTC](https://discourse.nodered.org/t/using-jsonata-to-filter-out-one-phone-number-from-a-fritzbox-phone-book/68493 "2022-10-02T17:40:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![haegar33](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haegar33/32/38805_2.png) [@haegar33](https://discourse.nodered.org/u/haegar33)\
**Post date:** [2 October 2022 17:40 UTC](https://discourse.nodered.org/t/using-jsonata-to-filter-out-one-phone-number-from-a-fritzbox-phone-book/68493/1 "2022-10-02T17:40:35Z")

</div>

I got a phonebook record list from my Fritzbox router with the following structure:

```auto
[{
    "category": "0",
    "person": {
        "realName": "Joe Blow"
    },
    "uniqueid": "507",
    "telephony": {
        "services": {
            "email": {
                "_": "some@mail.com",
                "$": {
                    "classifier": ""
                }
            }
        },
        "number": {
            "_": "0123456",
            "$": {
                "type": "mobile",
                "vanity": "",
                "prio": "1"
            }
        }
    }
}, 
...

```

I got a function node defined to search for a specific number but it might be more simple with one JSONata expresion like:

```auto
 *[telephony.number._ = "0123456"]

```

which gives me one matching record to process further.  
This works fine with a test setup and the fixed number in the JSONata Expression. But of course I want to inject any number in the change node to test for. However injecting a phone number in **msg.topic** with an a JSONata expression like:

```auto
 *[telephony.number._ = $lookup(msg.topic)]

```

does not work? Whats wrong with my syntax?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 October 2022 18:00 UTC](https://discourse.nodered.org/t/using-jsonata-to-filter-out-one-phone-number-from-a-fritzbox-phone-book/68493/2 "2022-10-02T18:00:31Z")

</div>

Lookup requires 2 inputs, an object and a key.

You could simply do

```auto
*[telephony.number._ = $$.topic]

```

---

<div class="post-metadata">

**Author:** ![haegar33](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haegar33/32/38805_2.png) [@haegar33](https://discourse.nodered.org/u/haegar33)\
**Post date:** [2 October 2022 18:17 UTC](https://discourse.nodered.org/t/using-jsonata-to-filter-out-one-phone-number-from-a-fritzbox-phone-book/68493/3 "2022-10-02T18:17:07Z")

</div>

classical situation to ignore the most simple approach 😉 Thanks!

---

<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 October 2022 18:17 UTC](https://discourse.nodered.org/t/using-jsonata-to-filter-out-one-phone-number-from-a-fritzbox-phone-book/68493/4 "2022-10-16T18:17:55Z")

</div>

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