I have this JSON array of objects:
payload:[
{name: "product1", price: 1.25},
{name: "product2", price: 1.35},
{name: "product1", price: 1.20},
{name: "product2", price: 1.30},
{name: "product3", price: 1.40}, etc
]
I'm trying to use JSONata to produce a new array with the average price for each product (grouped by product name) and ordered by the result of $average(price).
payload{name:$average(price)}^(?) // what does ? need to be
I basically want to know how to reference the value of each key/value pair for sorting/order-by use.
Thanks,