【问题标题】:How to map entire JSON object as value into new JSON key using JOLT?如何使用 JOLT 将整个 JSON 对象作为值映射到新的 JSON 键中?
【发布时间】:2019-05-27 10:27:47
【问题描述】:

我的目标是将 JSON 对象映射为新 JSON 对象键中的值。比如例子:

我的起始 JSON:

{
 "old_key_1" : "some_json_structure_1",
 "old_key_2" : "some_json_structure_2",
 "old_key_3" : "some_json_structure_3"
}

我的目标 JSON:

{
 "new_key_1" : 
  {
    "old_key_1" : "some_json_structure_1",
    "old_key_2" : "some_json_structure_2",
    "old_key_3" : "some_json_structure_3"
  }
}

如何使用 JOLT:如果我理解得很好,我必须使用换档规范,但我不明白如何使用?

谁能帮帮我?

提前谢谢你

【问题讨论】:

    标签: json jolt


    【解决方案1】:

    包装成新对象:

    [
      {
        "operation": "shift",
        "spec": {
          "*": {
            "@": "new_key_1.&" //the "&" means go up the tree 0 levels, grab what is there and subtitute it in
          }
        }
      }
    ]
    

    【讨论】:

    • 谢谢@Magda。它奏效了:我之前得到了这个解决方案,但我忘了把解决方案放在问题中。所以感谢为我做这件事并感谢您的解决方案!
    猜你喜欢
    • 1970-01-01
    • 2020-03-11
    • 1970-01-01
    • 1970-01-01
    • 2016-02-18
    • 2019-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多