简体   繁体   中英

How to use same field value at multiple places using JOLT library

I recently started working on jolt library,and it is very good in json to json transformation. But I am facing a few issues. One of them is I am not able to use a particular field at multiple places. For eg: input file contains timestamp field and output is a json array.I want to copy this in each array item.can anyone help here. Input and output will contain other fields also.

input : {"timeStamp":"21838188137282"} output: [{"time":"21838188137282"},{"time":"21838188137282"}{"time":"21838188137282"}]

Yes. If you use an Array / [] on the Right Hand Side of the shift transform, it will copy the input data to each of those places.

Spec

[
  {
    "operation": "shift",
    "spec": {
      "timeStamp": [ "[0].time", "[1].time", "[2].time" ]
    }
  }
]

Can test it at http://jolt-demo.appspot.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM