0

Input:

[{
    "Store_id": "store_0",
    "Item_id": "item_0",
    "Quantity": "26",
    "Date": "2019-05-01",

}, {
    "Store_id": "store_0",
    "Item_id": "item_0",
    "Quantity": "17",
    "Date": "2019-05-02"
}, {
    "Store_id": "store_0",
    "Item_id": "item_1",
    "Quantity": "47",
    "Date": "2019-05-01",
    "CREATED_DT": "2019-10-09 20:45:47.0",
    "CREATED_BY": "di_user"
}]

Output Required:

[order: {
    "Store_id": "store_0",
    "Date": "2019-05-01"
    items:[
          {item: item_0 , Quantity:26}]},
{
    "Store_id": "store_0",
    "Date": "2019-05-02"
    items:[
          {item: item_0 , Quantity:17}]}
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601

1 Answers1

0

If I read yours output correctly, below spec should work:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "Store_id": "order[&1].Store_id",
        "Date": "order[&1].Date",
        "Item_id": "order[&1].items[#].item",
        "Quantity": "order[&1].items[#].Quantity"
      }
    }
  }
]
Magda
  • 482
  • 4
  • 9
  • Thanks, Magda. But I want to group all the records based on matching Srore_id and Date. This Spec is giving only one record per grouping. for example, if I have 10 different Items for one store and one Date, I should have a array of all [{Item: item_id1,Quantity:Quant1}, {Item: item_id2,Quantity:Quant2},{Item: item_id3,Quantity:Quant3}, ...... So on] – Mandeep singh Oct 31 '19 at 20:23
  • Oh, now I see. I think that this answer is similar to yours problem: https://stackoverflow.com/questions/44674781/jolt-grouping-together – Magda Nov 04 '19 at 07:53