Code and/or JMESPath bug?

I’m getting the following result:

Whereas it should be:

As well as according to the n8n documentation:

n8n version 0.209.4

works fine in the Set node …

{{ $jmespath( $json.body.people, "[].[first, last]") }}

Although I still think that this may be a bug, I figured out that it does work when you add keys …

return $jmespath($input.all()[0].json.body.people, "[].{firstName: first, lastName: last}" )

Please not that if you’re using the JMESPath query ( to remove the “” around the key.

So [].{"firstName": first} in JMESPath needs to be [].{firstName: first} in n8n … both the in the Code and Set node

1 Like

Hi @dickhoning, yeah this looks odd but I agree that it probably just has to do with the lack of keys in your first screenshot and n8n trying to interpret the structure by itself.

If you return an array following n8n’s data structure in your code node this seems to work as expected:

Example workflow:

This is also what happens in your second example using the Set node. Here the example is returned as a value under the propertyName key inside a proper n8n data structure.

1 Like

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