skip to Main Content

JSONata grouping in new objects

I'm looking for a solution of grouping elements from a flat hierarchy into a encapsulated one with the help of JSONata. Given that I have the following input data: [ { "restaurantName": "Pizza Place", "restaurantId": "1", "dishName": "Margherita Pizza", "dishId":…

VIEW QUESTION

Jsonata filter group by parent element

I have json object as follows {"resources":[{"srno":"1","name":"name1","projects":[{"prjname":"abc"}]},{"srno":"1","name":"name1","projects":[{"prjname":"def"}]},{"srno":"2","name":"name2","projects":[{"prjname":"abc"}]},{"srno":"4","name":"name4","projects":[{"prjname":"prq"}]},{"srno":"4","name":"name4","projects":[{"prjname":"stu"}]},{"srno":"4","name":"name4","projects":[{"prjname":"uvw"}]},{"srno":"5","name":"name5"}]} How can I get resources grouped by id,name - each of that should contain list of projects? basically,flattened to structured i.e. {"resources":[{"srno":"1","name":"name1","projects":[{"prjname":"abc"},{"prjname":"def"}]},{"srno":"2","name":"name2","projects":[{"prjname":"abc"}]},{"srno":"4","name":"name4","projects":[{"prjname":"prq"},{"prjname":"stu"},{"prjname":"uvw"}]},{"srno":"5","name":"name5"}]} can someone share jsonata expression to create same

VIEW QUESTION
Back To Top
Search