颠簸变换后更改输出名称

Change output name after jolt transformation

我是jolt的新手,想知道有没有好的方法可以在转换后修改输出字段的名称

输入样本:

 {
      "userId": "1",
      "age": "20",
      "firstName": "firstname1",
      "lastname": "lastname1",
      "zipCode": "zipcode1",
      "street": "street1",
      "city": "city1",
      "country": "country",
      "gender": "gender1",
      "grade": "grade1",
      "birthday": "birthday1"
    }

规格示例 ==> 感谢@Barbaros 的帮助

[
  {
    "operation": "shift",
    "spec": {
      "userId": "ID",
      "*": "&",
      "street|city|zipCode|country": {
        "$": "adr_&.code",
        "@": "adr_&.value"
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "*": "&",
      "adr_*": "address[]"
    }
  }
]

输出

{
  "ID" : "1",
  "age" : "20",
  "firstName" : "firstname1",
  "lastname" : "lastname1",
  "address" : [ {
    "code" : "zipCode",
    "value" : "zipcode1"
  }, {
    "code" : "street",
    "value" : "street1"
  }, {
    "code" : "city",
    "value" : "city1"
  }, {
    "code" : "country",
    "value" : "country"
  } ],
  "gender" : "gender1",
  "grade" : "grade1",
  "birthday" : "birthday1"
}

所需的输出可能如下所示。我的意思是地址中字段代码的值,可以自定义(自定义字段):

{
      "ID" : "1",
      "age" : "20",
      "firstName" : "firstname1",
      "lastname" : "lastname1",
      "address" : [ {
        "code" : "**custom-field1**",
        "value" : "zipcode1"
      }, {
        "code" : "**custom-field2**",
        "value" : "street1"
      }, {
        "code" : "**custom-field3**",
        "value" : "city1"
      }, {
        "code" : "**custom-field4**",
        "value" : "country"
      } ],
      "gender" : "gender1",
      "grade" : "grade1",
      "birthday" : "birthday1"
    }

提前致谢。

在这种情况下,通过在 # 每个所需自定义值的通配符,因为它们没有公因数,例如

[
  {
    "operation": "shift",
    "spec": {
      "userId": "ID",
      "*": "&",
      "zipCode": {
        "#custom-field1": "adr_&1.code",
        "@": "adr_&.value"
      },
      "street": {
        "#custom-field2": "adr_&1.code",
        "@": "adr_&.value"
      },
      "city": {
        "#custom-field3": "adr_&1.code",
        "@": "adr_&.value"
      },
      "country": {
        "#custom-field4": "adr_&1.code",
        "@": "adr_&.value"
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "*": "&",
      "adr_*": "address[]"
    }
  }
]

站点 http://jolt-demo.appspot.com/ 上的演示是