Search code examples
jsonata

how to merge children to an array in jsonata


How can I merge the objects from "123" and "Trilby hat"

{
"123": {
"Price": 68.9,
"Qty": 2,
"ProductID": 858383
},
"Trilby hat": {
"Price": 21.67,
"Qty": 1,
"ProductID": 858236
}
}

to

{
"Items" : \[
{
"Price": 68.9,
"Qty": 2,
"ProductID": 858383
},  
{
"Price": 21.67,
"Qty": 1,
"ProductID": 858236
}
\]
}

here's the sample https://try.jsonata.org/Q84as3J_3


Solution

  • Select all the values using a wildcard:

    {
       "Items": *
    }
    

    https://try.jsonata.org/NoyeBo8MS