Extracting nested value from JSON with different key names

Hello

I have been working heavily on N8N these days (maybe my messages here are an indication :sweat_smile:)
I spent all day challenging myself to solve my issue but I tried everything I could think off and could not figure it out.

So I am calling an API that gives me public company accounts (nothing confidential) and I want to query a specific value and extract it.

My current workflow is the following:

  1. First node sets a company ID and a code
  2. Second node calls the account details through an HTTP request

For each year, for the code set in first node, I am trying to extract the value for the key “Montant brut annĂ©e N”.

Here it’s maybe clearer in this screenshot:

I have been trying to split and filter, also tried code using GPT4 with a dozen solutions but none worked as intended.

I made a simple workflow where I have added the HTTP request JSON output as set node for testing.
Unfortunately Discourse doesn’t let me paste it because the JSON is too large so you will find the workflow ready to copy paste here: { "meta": { "instanceId": "1d17b93da6a4dfec32237d10fc41b01c9bcb5fe4cfc1f - Pastebin.com

Could anyone give me a hand here? I would really appreciate it.

Thank you!

Hi @Joachim_Brindeau, I reckon you want one item per year here? @nico-kow recently shared a possible approach converting columns into rows/items working quite well here. With a little tweaking it can return the data for one year per row, for example like so.

You can then reduce the result further using additional Set nodes. Since there is more than one Montant brut annĂ©e N value for each year it wasn’t quite clear to me what output exactly you’d like to see, but if you can provide an example of what exactly you’re looking for we might be able to help :slight_smile:

1 Like

That first step was exactly what I am looking for!
Thanks a lot, I’ll put that in place!

1 Like

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