bazaarvoice / jolt

JSON to JSON transformation library written in Java.
Apache License 2.0
1.56k stars 329 forks source link

Extra NULLS in output - Defect #1213

Open Cp3022 opened 1 year ago

Cp3022 commented 1 year ago

why do we get NULL values at the root level. (null, null, null, null, null, null, null, null, null, null)?

Input json:

{
  "0000100001": {
    "10": [
      {
        "id": "0000301010",
        "name": "ATR42/72, Initial Pilot",
        "code": "017IP",
        "description": "desc",
        "division": {
          "id": "10",
          "name": "Flight / Pilot",
          "courses": []
        },
        "manufacturer": "amnu",
        "program": {
          "id": "0000100001",
          "name": "ATR 42/72",
          "divisions": []
        }
      }
    ],
    "30": [
      {
        "id": "0000301011",
        "name": "ATR42/72, Recurrent Pilot",
        "code": "017RP",
        "description": null,
        "division": {
          "id": "10",
          "name": "Flight / Pilot",
          "courses": []
        },
        "manufacturer": null,
        "program": {
          "id": "0000100001",
          "name": "ATR 42/72",
          "divisions": []
        }
      }
    ]
  }
}

Spec:

[
  {
    "operation": "shift",
    "spec": {
      "0000100001": { //program level key
        "*": { //division level
          "*": { //each array record
            "id": "[&2].divisions.course.id",
            "name": "[&2].divisions.course.name",
            "code": "[&2].divisions.course.code",
            "division": {
              "id": "[&3].divisions.id",
              "name": "[&3].divisions.name"
            },
            "program": {
              "id": "[&3].id",
              "name": "[&3].name"
            }
          }
        }
      }
    }
  }
]

Results:


[
 null, null, null, null, null, null, null, null, null, null, {
  "divisions" : {
    "course" : {
      "id" : "0000301010",
      "name" : "ATR42/72, Initial Pilot",
      "code" : "017IP"
    },
    "id" : "10",
    "name" : "Flight / Pilot"
  },
  "id" : "0000100001",
  "name" : "ATR 42/72"
}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, {
  "divisions" : {
    "course" : {
      "id" : "0000301011",
      "name" : "ATR42/72, Recurrent Pilot",
      "code" : "017RP"
    },
    "id" : "10",
    "name" : "Flight / Pilot"
  },
  "id" : "0000100001",
  "name" : "ATR 42/72"
} ]

Thanks