jmesPath, extracting keys starting with "text"

Just hit a wall with jmesPath, maybe someone has an idea how to solve that elegantly:

I’ve got this simplified JSON (from a webhook):

               "value":"John Doe",
               "title":"Vor- & Nachname"
               "value":"[email protected]",
               "title":"Deine E-Mail Adresse"

The symbols in the question keys are random after “question_”.
I want one string field, where all questions with answers are combined in a human-readable format.
Something like that:

Question1: Answer1
Question2: Answer2

I thought about doing it with jmesPath in an expression in a Set node, as I already have a Set node there to clean up the data.

Here’s my last attempt, I only get an empty object with that.

{{ $jmespath($json.body.profile, "[?starts_with(@, 'question_')].json") }}

I would greatly appreciate any suggestions on how to accomplish this.

test workflow

Hi @FelixL, I can’t think of an elegant way of solving this with JMESPath tbh (there probably is one though, I just can’t figure it out today). Perhaps you just want to use vanilla JS instead?

Something like this:

This would be the result, returned in a single message field:

1 Like

Hi @MutedJam, yep already thought about using a code node too, just wanted to know if there is an alternative, as I am trying to reduce my use of the code node.

Thanks for taking the time to write out a solution. :slightly_smiling_face:

1 Like

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