转换两个不同集合中的输入 json 与输入 json 共享相同的属性

问题描述 投票:0回答:1

输入 JSON 示例

{
  "name": "XYZ",
  "lastName": "PQR",
  "address": "abc, mnop, 534291"
}

具有共享属性的预期输出 JSON

{
  "employee": {
    "name": "XYZ",
    "lastName": "PQR",
    "address": "abc, mnop, 534291"
  },

  "address": {
    "name": "XYZ",
    "lastName": "PQR",
    "address": "abc, mnop, 534291"
  }
}
json transformation jolt
1个回答
0
投票

您可以在 shift

 转换中一起使用 
*
@ 通配符,如下所示:

[
  {
    "operation": "shift",
    "spec": {
      "*": "address.&", // this needs an ampersand to replicate the whole content
      "@": "employee"   // while this one doesn't
    }
  }
]

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

© www.soinside.com 2019 - 2024. All rights reserved.