Array parsing question

Is there a way parse an array without a function node? For example, if the data I'm receiving is in the form: msg.payload.value[0-9].anothervalue, can I split it and grab the 10 anothervalues without doing a for loop in a function? Thanks.

Yes - split node

msg.payload --> split --> change node --> join --> result

Yes by using Jsonata in a change node.
The expression would be something like


example flow


Sorry I'm not clear how that would work. The msg.payload looks like this:

  • payload
    -- values
    --- value [0 ... 9]
    ---- 0
    ----- string
    ----- string2
    ---- 1 (etc etc up to 9)
    --- value [10 ... 19]
    ---- etc etc up to the end of the array

So I'm trying to figure out if there's a way for NR to get me all those string and string2 without using a for loop in a function node.

I understand change node and splitting; what I don't understand is the formatting (if it exists) like if I want to extract all the values of "string" from above, is the Change Node set msg.payload to... to what? msg.payload.values.value[XXXX].string ? Thanks.

best to use the copy value button in debug node, it appears when you hover mouse to right of payload object. Then paste here using </> botton.
Then supply the output you want from that array, i.e.[string,string1,string,string1]
or [[string,string1],[string,string1]], etc. Then it will be clear what the input is and what the output should look like.

Also do you wish to do this in a function node or outside.

Here - has 140 array values broken up into chunks of 10 ([0-9], [10-19], etc.) starting with[0]. Each value in the array contains a timestamp which looks like this[0].validTime.

I'm trying to extract the 140 validTime values without involving a Function node at all. Is there a way to do that or is it impossible in NR without writing a function?

I don't understand the point not to use a function. Unless you like to make your Life harder


If that is the valid path, then the jsonata expression to use in a change node would be
and it would return 140 validTime values in an array

Again if you supply a sample data and what you want outputted, then i would provide an example

That in conjunction with split worked great. I don't know Jsonata so it didn't even occur to me that it might be an option for my use case so thanks.

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