2

I'm facing an issue with implementing my Jolt Spec to transform this input.

input:

[
  {
    "organizationName": "TOTOLAND",
    "organizationUid": "123456789",
    "usageByLicenseAndProduct": [
      {
        "productType": "VSPC",
        "licenseEdition": "Enterprise Plus",
        "workloadUsage": [
          {
            "workloadType": "VAC_Workstation_Agent"
          },
          {
            "workloadType": "VAC_Server_Agent"
          }
        ]
      }
    ]
  },
  {
    "organizationName": "TOTOLAND2",
    "organizationUid": "456789",
    "usageByLicenseAndProduct": [
      {
        "productType": "VSPC",
        "licenseEdition": "Enterprise Plus",
        "workloadUsage": [
          {
            "workloadType": "VAC_Workstation_Agent"
          }
        ]
      },
      {
        "productType": "BackupAndReplication",
        "licenseEdition": "Enterprise Plus",
        "workloadUsage": [
          {
            "workloadType": "VAC_Workstation_Agent"
          }
        ]
      }
    ]
  }
]

Output:

[
  {
    "organizationName": "TOTOLAND",
    "organizationUid": "123456789",
    "productType": "VSPC",
    "licenseEdition": "Enterprise Plus",
    "workloadType": "VAC_Workstation_Agent"
  },
  {
    "organizationName": "TOTOLAND",
    "organizationUid": "123456789",
    "productType": "VSPC",
    "licenseEdition": "Enterprise Plus",
    "workloadType": "VAC_Server_Agent"
  },
  {
    "organizationName": "TOTOLAND2",
    "organizationUid": "456789",
    "productType": "VSPC",
    "licenseEdition": "Enterprise Plus",
    "workloadType": "VAC_Workstation_Agent"
  }
]

I tried multiple Jolt Specs via jolt-demo.appspot.com, but I failed to have a satisfying transformation...

Could you help me? Thanks a lot! Gatien

Mohammadreza Khedri
  • 2,523
  • 1
  • 11
  • 22

1 Answers1

0

You can use this spec:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "usageByLicenseAndProduct": {
          "*": {
            "workloadUsage": {
              "*": {
                "*": "@(5,organizationUid).@(3,productType).@(1,workloadType).&",
                "@(4,organizationName)": "@(5,organizationUid).@(3,productType).@(1,workloadType).organizationName",
                "@(4,organizationUid)": "@(5,organizationUid).@(3,productType).@(1,workloadType).organizationUid",
                "@(2,productType)": "@(5,organizationUid).@(3,productType).@(1,workloadType).productType",
                "@(2,licenseEdition)": "@(5,organizationUid).@(3,productType).@(1,workloadType).licenseEdition"
              }
            }
          }
        }
      }
    }
  },
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "@": "[]"
        }
      }
    }
  }
]
Mohammadreza Khedri
  • 2,523
  • 1
  • 11
  • 22