对象json数组

时间:2018-09-02 09:30:24

标签: java json jolt

输入Json对象

  {
    "Customer": {
        "CustomerName": "John Miller",
        "CustomerType": "Banker",
        "Attribute1": "",
        "Attribute2": "",
        "Attribute3": "",
        "Attribute4": "",
        "Contacts": [
          {
            "ContactIdentifier": "Contact1",
            "Attribute1": "",
            "Attribute2": "",
            "Attribute3": "",
            "Attribute4": "",
            "Addresses": [
              {
                "AddressIdentifier": null,
                "AddressLine1": "a1",
                "AddressLine2": "b1",
                "AddressLine3": "c1",
                "Attribute1": "d1",
                "Attribute2": "e1"
              },
              {
                "AddressIdentifier": "2",
                "AddressLine1": "a2",
                "AddressLine2": "b2",
                "AddressLine3": "c2",
                "Attribute1": "d2",
                "Attribute2": "e2"
              }
            ]
          },
          {
            "ContactIdentifier": "Contact2",
            "Attribute1": "",
            "Attribute2": "",
            "Attribute3": "",
            "Attribute4": "",
            "Addresses": [
              {
                "AddressIdentifier": "11",
                "AddressLine1": "a11",
                "AddressLine2": "b11",
                "AddressLine3": "c11",


      "Attribute1": "d11",
                    "Attribute2": "e1"
                  },
                  {
                    "AddressIdentifier": "21",
                    "AddressLine1": "a21",
                    "AddressLine2": "b21",
                    "AddressLine3": "c21",
                    "Attribute1": "d21",
                    "Attribute2": "e21"
                  }
                ]
              }
            ]
          }
        }

预期产量

{
  "Customer": {
    "CustomerName": "John Miller",
    "CustomerType": "Banker",
    "Contacts": [
      {
        "ContactIdentifier": "Contact1",
        "Addresses": [
          {
            "AddressIdentifier": null,
            "AddressLine1": "a1",
            "AddressLine2": "b1",
            "AddressLine3": "c1"
          },
          {
            "AddressIdentifier": "2",
            "AddressLine1": "a2",
            "AddressLine2": "b2",
            "AddressLine3": "c2"
          }
        ]
      },
      {
        "ContactIdentifier": "Contact2",
        "Addresses": [
          {
            "AddressIdentifier": "11",
            "AddressLine1": "a11",
            "AddressLine2": "b11",
            "AddressLine3": "c11"
          },
          {
            "AddressIdentifier": "21",
            "AddressLine1": "a21",
            "AddressLine2": "b21",
            "AddressLine3": "c21"
          }
        ]
      }
    ]
  }
}

我正在尝试使用颠簸移位操作,但我想我缺少一些东西。我无法复制JSON对象的数组。通过使用其他一些通配符运算符,是否还有其他方法可以迭代对象数组。这里我不想使用remove操作,因为接触级别的对象太多了,一一删除并不听起来很酷。

任何帮助将不胜感激。

预先感谢

[
  {
    "operation": "shift",
    "spec": {
      "Customer": {
        "CustomerName": "CustomerName",
        "CustomerType": "CustomerType",
        "Contacts": {
          "*": {
            "ContactIdentifier": "Contacts[#].ContactIdentifier",
            "Addresses": {
              "*": {
                "AddressIdentifier": "Contacts[#].Addresses[#].AddressIdentifier",
                "AddressLine*": "Contacts[#].Addresses[#].&"
              }
            }
          }
        }
      }
    }
  }
]

0 个答案:

没有答案