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

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

    "category": "0",
    "person": {
        "realName": "Joe Blow"
    "uniqueid": "507",
    "telephony": {
        "services": {
            "email": {
                "_": "",
                "$": {
                    "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:

 *[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:

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

does not work? Whats wrong with my syntax?

Lookup requires 2 inputs, an object and a key.

You could simply do

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

classical situation to ignore the most simple approach :wink: Thanks!

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