Restructuring JSON response

Describe the issue/error/question

Hi, I am trying to structure a JSON response, since as it is it not useful for me.

I am requesting recipes for a single item via a filter (i.e. Lemon cheesecake) and then I get following:

"recipes": {
"Lemon Cheesecake": [
{
"id": 1,
"name": “Lemon Cheesecakse”,
"category": “cake”,
"location": “UK”,
"description": “lemon Cheesecake is not an original UK recipe but is widely known…”,

Issue is that if I request “Brownie” I would get:

"recipes": {
"Brownie": [
{
"id": 3,
XXXXX
I only want the data after “Brownie/Lemon cheesecake”, but because of this, I cannot use a “SET” action just to leave what I need, as the previous line is dynamic.

Is there way of solving this? Thank you very much.

Hey @Jorge_M, so you want to read whatever data comes first in your recipes object without knowing the exact name of the first key?

If so, you could use Object.keys() to get all keys and then simply use the first key you get so you don’t need to know its name. This would also work in a Set node:

Here is an example workflow showing the idea:

Hope this helps!

1 Like

Hi @MutedJam ,
Correct, I don’t need to know because I already used it to call the API itself in the query parameters, by removing that part, I can then use the SET and make multiple requests to then group data. Thank you very first, I will make a test :).

Amazing @MutedJam ,thanks, it worked perfectly, very grateful for this :slight_smile: .

2 Likes