根据Jolt中的另一个键/值条目更新键/值条目

时间:2019-12-16 12:47:51

标签: jolt

请,我有以下

输入json:

{   
"Input State": "CANCELLED",   
"RestoredDate": "02/12/2019",  
 "value": "30" 
}

和我的

震动规格:

[   
{
     "operation": "shift",
     "spec": {
       "RestoredDate": ["Initial Date", "Completed Date"],
       "value": "VALUE",
       "Input State": "State"
     }   },   {
     "operation": "shift",
     "spec": {
       "State": {
         "CANCELLED": {
           "# ": "Initial Date"
         }
       }
     }   
    }
    ]

输出:

{
      "Initial Date" : " 02/12/2019",
     "Completed Date" : "02/12/2019",
      "VALUE" : "30",
      "State" : "CANCELLED"
    }

当输入状态为“取消”时,我想将“初始日期”设置为空。 并在输入状态未取消时更新完成日期(将日期增加3,例如05/12/2019)。

因此,鉴于此输入:

{   
"Input State": "CANCELLED",   
"RestoredDate": "02/12/2019",  
 "value": "30"
 }

我想要输出:

{
  "Initial Date" : " ", //Initial Date is empty because Input State is CANCELLED
 "Completed Date" : "02/12/2019",
  "VALUE" : "30",
  "State" : "CANCELLED"
}

并给出以下输入:

{
  "Input State": "AUTHORIZED", //Not Cancelled
  "RestoredDate": "03/12/2019",
  "value": "30"
}

输出:

{
  "Initial Date" : "03/12/2019",
  "Completed Date" : "06/12/2019", //Completed Date has days increased by 3. While Initial Date is unchanged.
  "VALUE" : "30",
  "State" : " AUTHORIZED "
}

0 个答案:

没有答案