简体   繁体   English

如何使用JOLT库在多个位置使用相同的字段值

[英]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. 我最近开始研究jolt库,在json到json的转换中非常好。 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. 例如:输入文件包含时间戳字段,输出是一个json数组。我想将其复制到每个数组项中。 Input and output will contain other fields also. 输入和输出还将包含其他字段。

input : {"timeStamp":"21838188137282"} output: [{"time":"21838188137282"},{"time":"21838188137282"}{"time":"21838188137282"}] 输入:{“ timeStamp”:“ 21838188137282”}输出:[{“ 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. 如果在shift转换的右侧使用Array / [],它将把输入数据复制到每个位置。

Spec 规格

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

Can test it at http://jolt-demo.appspot.com/ 可以在http://jolt-demo.appspot.com/上对其进行测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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