Searching through json data for individual strings within the strings

Howdy! I am looking into some json data. I have parts of names, or longer names. The json provided is a list of randomly gathered data to match.

For example, I have an employee named John Doe. They could be within the json as their email, full name, or a concatenation of their name (as follows).

I have tried using list compare, merge, if statements. But I seem to be missing something.

The goal is to output only the data that has any of the names in a full list, within the janky list.

For example, the full list can include:

[   
    {
        "name": "John Doe"
    },
    {
        "name": "Jane Frances Dough"
    }
]

and I am provided this janky list:

[   
    {
        "name": "[email protected]",
        "ID": 1
    },
    {
        "name": "J Dough"
        "ID": 2
    },
    {
        "name": "Bob Barker"
        "ID": 3
    },
    {
        "name": "Barker"
        "ID": 4
    }
]

It should return:

[   
    {
        "name": "[email protected]",
        "ID": 1
    },
    {
        "name": "J Dough"
        "ID": 2
    }
]

The closest I THINK I have come, is this:
It grabs the name from the incoming node, and searches the list of good names in another node. Adds true or false if it is there within the current node json. This would be used later in an if statement to do what is needed. I get an error to start with the toLower() not working. But besides that I THINK it is the right path?

Oh boy, that’s quite a challenge. While the Merge node can compare two lists, it would do exact matches rather than the custom matching you have in mind. So I think your custom code approach is the best idea.

Perhaps something like this would do the job for you?

This would return the result you have in mind (a new field to be used in a subsequent If node), though I am not sure I fully understood all matching requirements here:

Let me know if you have any questions on this :slight_smile:

2 Likes

This is brilliant, thank you so much

1 Like

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