如何使用Jolt在JSON数组之后添加元素

时间:2018-11-14 20:00:04

标签: json jolt

我的示例json看起来像这样


    {  
       "Event":{  
          "EventHeader":{  
             "size":57,
             "eventTime":"2018-11-02T20:31:15.428"
          },
          "EventData":{  
             "record":"XXXXX",
             "time":"201805270343",
             "count":11,
             "passengers":[  
                {  
                   "name":"DOE/JOHN",
                   "details":{  
                      "genderCode":"M",
                      "birthDate":"19900502",
                      "personName":{  
                         "lastName":"DOE",
                         "firstName":"JOHN",
                         "middleName":null
                      }
                   }
                }
             ],
             "flightCount":0,
             "ticketed":{  
                "typeCode":null,
                "comments":"ABCD"
             },
             "telephoneCnt":0
          }
       }
    }
and the desired  output look like this 

 <pre>{  
   "Event":{  
      "EventHeader":{  
         "size":57,
         "eventTime":"2018-11-02T20:31:15.428"
      },
      "EventData":{  
         "record":"XXXXX",
         "time":"201805270343",
         "count":11,
         "passengers":[  
            {  
               "name":"DOE/JOHN",
               "details":{  
                  "genderCode":"M",
                  "birthDate":"19900502",
                  "personName":{  
                     "lastName":"DOE",
                     "firstName":"JOHN",
                     "middleName":null
                  }
               }
            }
         ],
         "paxend":"true",
         "flightCount":0,
         "ticketed":{  
            "typeCode":null,
            "comments":"ABCD"
         },
         "telephoneCnt":0
      }
   }
}

基本上我想在“乘客”数组之后添加“ paxend”:“ true”。我们如何使用Jolt实现这一目标?非常感谢您的帮助。对于无法发布我的震动说明,我感到很抱歉,因为它不起作用。

1 个答案:

答案 0 :(得分:1)

因此,这会将Super expression must either be null or a function添加到EventData中,但是没有现成的方法可以将其正确地放置在“ passengers”数组以下。这是一个JSON映射,顺序无所谓。

规格

"paxend": "true"