如何使用 jolt 在 json 中添加 value=current_timestamp 的键值标签

How to add key value tag with value=current_timestamp in json using jolt

我正在尝试使用 jolt 将 JSON 转换为 JSON,我有以下示例 JSON 想要转换为预期的 JSON。你能用 jolt 库帮我解决这个问题吗?我还想添加一个新的键值对 "created_ts" 标签,它将在预期的 JSON.

中保存当前时间戳的值

样本JSON

{
  "name": "SAMPLE_NAME",
  "timeStamp": "1477307252000",
  "value": "-0.06279052",
  "quality": "1090"
}

预期输出 JSON:

{
  "name": "SAMPLE_NAME",
  "timeStamp": "2016-11-08 14:46:13.674",
  "value": "-0.06279052",
  "quality": "1090",
  "created_ts": "2016-11-08 14:46:13.674"
}

保持简单, 使用具有此配置的 replaceText 处理器:

Search Value         :  }\s+}
Replacement Value    :  { "created_ts":"${now()}",
Replacement Strategy :  Regex Replace
Evaluation Mode      :  Entire text

Jolt 目前不提供 "Out of the Box" 方式来进行 String/Number/Date 转换。