cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to 'flatten' array using a mapper and pull out values

Auroth
New Contributor

Hi Everyone, I am trying to pull the 'TDLINE' elements out of the weirdly structured array shown below. Normally for something like this I would use a .filter() with a .map() - something like the following. .filter(x => x.get('TDFORMAT') == '/').map(x => x.get('TDLINE')).

Auroth_0-1745504383125.png

However, running the code above gives me an error about how a list type does not have the function '.get()'. I presume this is because of the weird structure of the array above -- or maybe it's being stored as a list, which maybe is different than the array?

Anyways, I am just trying to pull out all the TDLINE elements and get them into an array where I can then push that out to an endpoint later. Does anyone have any ideas on how to do so?

Thanks in advance

1 REPLY 1

koryknick
Employee
Employee

@Auroth - I believe what you are looking for is:

jsonPath($, "$tdline_array..TDLINE")

jsonPath is a tool that lets you perform powerful scans through JSON.  In this case, I'm using the descent operator (..) to search for TDLINE regardless of where it exists in the JSON document.

If you're already comfortable with Object and Array functions, this is your complement to those expressions.

Hope this helps!