地图颠簸变换

Map Jolt Transformation

我正在尝试转换以下输入:

{
    "test_types": {
        "3": "Type3",
        "21": "type21",
        "16": "Type16",
        "15": "type15"
    },
    "name": "BlackSquid",
    "obj_name": "malware",
    "value": "2341743",
    "type": "16"
}

进入此输出:

{
    "test_types": {
        "3": "Type3",
        "21": "type21",
        "16": "Type16",
        "15": "type15"
    },
    "name": "BlackSquid",
    "obj_name": "malware",
    "value": "2341743",
    "type": "16",
    "type_name": "Type16"
}

我已尝试通过对键值进行硬编码来使用“修改覆盖测试版”规范,从而得到我需要的结果:

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "type_name": "@(1,test_types.16)"
    }
  }
]

但我想动态地使用“类型”值。以下抛出异常但可能是这样的:

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "type_name": "@(1,test_types.@(1,type))"
    }
    }
]

无需使用 modify-overwrite-beta 规范,但需要使用基于条件的 shift 规范 type 就足够了,例如


[{
  "operation": "shift",
  "spec": {
    "*": "&",
    "type": {
      "*": {
        "@(2,type)": "type",
        "@(2,test_types.&)": "type_name"
      }
    }
  }
}]