How-to - Filter json output - One value



How-to - Filter json output and get one value.

What would be the best and quick way to accomplish that.

For example, if I have the following json output

"data": "{"public_ip":"","region":"Ontario","country":"Canada","city":"Toronto","location":"43.7001,-79.4163","organization":"AS46562 Performive LLC","postal_code":"M5A","timezone":"America/Toronto"} "

and I want to get the public_ip output only


Example that is working with javascript when running in browser

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <title>Convert JSON String to JavaScript Object and Access Individual Values</title>
    // Store JSON data in a JS variable
    var json ='{"public_ip":"","region":"Ontario","country":"Canada","city":"Toronto","location":"43.7001,-79.4163","organization":"AS46562 Performive LLC","postal_code":"M5A","timezone":"America/Toronto"}';
    // Converting JSON-encoded string to JS object
    var obj = JSON.parse(json);
    // Accessing individual value from JS object
    document.write(obj.public_ip + "<br>"); // Prints:
    document.write(obj.region + "<br>"); // Prints: Ontario
    document.write(; // Prints: Canada

Hi @ansred, you can use a logic similar to your browser logic in n8n. n8n expressions contain JavaScript, so you could parse your JSON-like string and read the public_ip property like so:

So pretty much what you already have just wrapped inside JSON.parse() with an added .public_ip:


Hope this helps!

1 Like

That helped indeed. Quick and straightforward!
Thank you @MutedJam !!!

1 Like