Sorting Values - JSON

Hi Everyone,

I'm really new to all of this!

I currently have a UDP stream of scoreboard data and I can parse it with CSV and JSON and then output it to a file that my graphics system can look at.

What I'm trying to do now, is sort that data based on a particular column's data. Done some Googling and tried a few things on here to no avail.

Any help would be greatly appreciated!

Many thanks

You can use the change node to sort the object using JSONata expression :J $$.payload^(name)
that would sort msg.payload by the property name. Adding < or > before name would set ascending or descending, to order by more properties just and property names separated by a comma

I would help more but you offer no data to give you a working example.

Hi, thanks for getting back to me.

This is how the data currently comes out:

msg.payload : array[9]
array[9]
0: object
col1: "1"
col2: "Emily Cocksedge"
col3: "Hertford"
col4: " 16.75"
col5: "2"
col6: " 1"
col7: null
1: object
col1: "2"
col2: "Xenia Coole"
col3: "Essex"
col4: " 17.14"
col5: "4"
col6: " 1"
col7: null

etc.

I'd like to sort by "col5"

That would be
$$.payload^(col5)

Perfect! Exactly what I needed. Thank you!

When you copy data to the forum it is necessary for the data to be presented in a usable format and correctly formatted using the </> button.

Look at the copy value button that appears under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

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