Filter json

I have this json result. I need to get link result.

The problem is each time i make a query, json result is not ordered, so the link can be in item0 or in item 10.

This is my json:
[

{

“id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“object”: “item”,

“folder_id”: “aGGC4jHnPSt”,

“created_at”: “2022-05-16T21:27:12.000000Z”,

“sort_order”: “73728.000000000000000000000000000000”,

“values”: [

{

“id”: “143a9f6d-c015-49ec-bd6a-54272aa271cf”,

“object”: “value”,

“data”: [

],

“attribute_id”: “772d6375-bdf4-4086-8e76-72a02b899771”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “67bc0a2a-ef2f-45ce-a000-cae28de1259c”,

“object”: “value”,

“data”: [

{

“id”: 3153385,

“link”: “https://google.pt”,

“path”: “item-files/xxxx/ILkW6tZXY6vHpgmG48d5ukcRqcZI6mthNOuZCwIo.jpeg”,

“original_name”: “133.jpeg”,

“filesize”: 4768330,

“thumb”: “AAA Sorry Page”,

“created_at”: “2022-05-16T21:31:26.000000Z”,

“updated_at”: “2022-05-16T21:31:26.000000Z”,

“team_id”: 1234,

“deleted_at”: null,

“checked_at”: null,

“extension”: “jpeg”,

“basename”: “133.jpeg”,

“filename”: “133”

}

],

“attribute_id”: “ed748576-2e45-437b-8a9d-a9d3d154155e”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “96a72224-c47a-43d0-95fd-0209cac88064”,

“object”: “value”,

“data”: [

{

“id”: 3161516,

“link”: “https://www.google.pt”,

“path”: “item-files/xxxx/9BIg1umP3x8hFmexWbB9X4O1CjhVyeA5I07o5d0L.png”,

“original_name”: “5c2bcdae-7162-425d-bd9f-01819d61e76f.png”,

“filesize”: 2927019,

“thumb”: “AAA Sorry Page”,

“created_at”: “2022-05-17T23:27:43.000000Z”,

“updated_at”: “2022-05-17T23:27:43.000000Z”,

“team_id”: 54044,

“deleted_at”: null,

“checked_at”: null,

“extension”: “png”,

“basename”: “5c2bcdae-7162-425d-bd9f-01819d61e76f.png”,

“filename”: “5c2bcdae-7162-425d-bd9f-01819d61e76f”

}

],

“attribute_id”: “a9b9f4b7-3f2b-435a-8c53-661ca2639797”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “a97fafdd-7530-4f6c-8c71-5f8b3109902d”,

“object”: “value”,

“data”: [

],

“attribute_id”: “1522e69a-b59e-46b1-adbe-0fb6601ac340”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “200c0894-98ed-48b2-906f-fbeeffd15c89”,

“object”: “value”,

“data”: 11,

“attribute_id”: “a2fd8f91-805b-40f0-9ffd-308a00c49d94”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “3f8fbdc8-82d0-4c8c-8926-d9c7e409e399”,

“object”: “value”,

“data”: true,

“attribute_id”: “efc85277-2ffa-4139-ba42-40d4b3170792”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “5aaca828-38c2-4c4c-8c07-11ad2c2e390e”,

“object”: “value”,

“data”: false,

“attribute_id”: “b9dab3ed-47b6-49e3-a8f5-50e40a5f5a9d”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “79645fcc-23ba-4102-b300-e4bf4380f1cd”,

“object”: “value”,

“data”: false,

“attribute_id”: “02727a1e-8aad-4bda-b77e-a6e749c0d4e6”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “8fdc1fc7-84eb-450e-9903-70a71c584089”,

“object”: “value”,

“data”: false,

“attribute_id”: “348827dd-bf6a-40cb-a8d0-1baf668ac205”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “473bff3f-311d-4113-a6db-25a3a4a452ce”,

“object”: “value”,

“data”: “2022-05-26T21:27:14.000000Z”,

“attribute_id”: “314fed70-6401-4cd7-ab54-45ea929be590”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “7d4050f5-2510-4d6a-8104-e98784b1ad3b”,

“object”: “value”,

“data”: “a”,

“attribute_id”: “95fc8595-c022-4f8e-a4d1-6981d4a85d36”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “b8909704-1ccc-46ca-a401-d0308eb5ad7c”,

“object”: “value”,

“data”: “b”,

“attribute_id”: “f2d0b7ad-2002-46b9-9734-254ede607669”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “92d5362a-2f6e-4ed6-8376-b94630956fc1”,

“object”: “value”,

“data”: “

tesrt

”,

“attribute_id”: “cbe1fe1a-1350-4b4a-b69c-f7f3de7ceba9”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

},

{

“id”: “b0a95ae1-6cd7-4809-8cc8-1ba9956e9fd2”,

“object”: “value”,

“data”: [

“f29212cf-2ce5-4eca-ae09-65cb6ec17f53”

],

“attribute_id”: “54bc748e-6d9f-4b3a-b431-1ec8a9fff86a”,

“item_id”: “36afbfe8-0741-454a-b81a-ab6b036fa47d”,

“deleted”: false

}

],

“deleted”: false

}

]

What flow have you tried creating in n8n? It looks like you can do something in a FunctionItem and then do a forEach

1 Like

This is probably a good candidate for JMESPath.

I’m not sure of your exact data structure (try using code tags in future), but this might help. The crux of it is in the Set node with {{ $jmespath($json["data"], '[].values[].data[].link') }}.

Here’s a great site to test your JMESPath live - Jmespath Tester | Online tool for testing JMESPath queries against JSON

2 Likes

Thanks it works.

After that i also applyed one filter, because i only want one link!
{{$jmespath($json.values, “[?attribute_id==‘ed748576-2e45-437b-8a9d-a9d3d154155e’]” )}}

Thanks, this save my day :slight_smile:

1 Like

Can you help with this:
This is ok and searching correctly
{{$jmespath($json.data, “[?uuid == ‘97906613-4413-4f99-a4ec-da85b13b1951’ ]” )}}

But now i want a variable to search in uuid. So i´m using $node.GetPhoneNumber1.json.uuid but it doesn´t work.
{{$jmespath($json.data, “[?uuid == ‘$node.GetPhoneNumber1.json.uuid’ ]” )}}

How could be this expression?

Hi @lsoldado - as this topic is quite old, can you please make a new thread and fill out the template that we provide? That will help us know as much about your n8n setup as possible and how we can help!