Garmaine Staff asked 1 year ago

I'm trying to transfer the JSON file below to another format, the phoneNumberType should be changed like this:

mobile -> MOBILE

home -> LANDLINE

work -> OFFICE

unspecified -> OTHER

really have no idea, anyone could help?

input:

{
  "eventOrdinal": 1555952128591,
  "personalInfo": {
    "phoneNumbers": [
      {
        "phoneNumberType": "mobile",
        "phoneNumber": "11111111111"
      },
      {
        "phoneNumberType": "home",
        "phoneNumber": "2222222222"
      },
      {
        "phoneNumberType": "work",
        "phoneNumber": "33333333333"
      },
      {
        "phoneNumberType": "unspecified",
        "phoneNumber": "4444444444444"
      }
    ]
  }
}

expected:

{
  "user": {
    "identity": {
      "phoneNumbers": [
        {
          "operation": "CREATE_OR_REPLACE",
          "version": 1555952128591,
          "values": [
            {
              "number": "11111111111",
              "telephoneType": "MOBILE"
            },
            {
              "number": "2222222222",
              "telephoneType": "LANDLINE"
            },
            {
              "number": "33333333333",
              "telephoneType": "OFFICE"
            },
            {
              "number": "4444444444444",
              "telephoneType": "OTHER"
            }
          ]
        }
      ]
    }
  }
}