SeleniumNewbe
SeleniumNewbe

Reputation: 85

Jolt Transformation problems with null Elements

I have a problem with my Jolt transformation but no idea how to fix it. I get "null" Element in the array I produce:

{
  "Verkaufsprodukt": [
    {
      "Produkt": [
        {
          "Elementarprodukt": [
            {
              "ArtID": {
                "bezeichnung": "b",
                "value": "0302"
              },
              "VersichertePerson": {
                "PartnerID": "1"
              }
            },
            {
              "ArtID": {
                "bezeichnung": "f"
              },
              "VersichertePerson": {
                "PartnerID": "1"
              }
            },
            {
              "ArtID": {
                "bezeichnung": "c"
              },
              "VersichertePerson": {
                "PartnerID": "1"
              }
            },
            {
              "ArtID": {
                "bezeichnung": "a",
                "value": "0301"
              },
              "VersichertePerson": {
                "PartnerID": "1"
              }
            }
          ]
        }
      ]
    }
  ],
  "Partner": [
    {
      "Name": "Holgerson",
      "PartnerID": "1",
      "Vorname": "Nils"
    }
  ]
}

My result:

{
 "vertragsdetails" : {
   "versichertePersonen" : {
     "versicherungssummenOderLeistungen" : [ null, {
       "kennung" : "0302"
     }, null, {
       "kennung" : "0301"
     } ]
   }
 }
}

Here is my spec:

[
  {
    "operation": "shift",
    "spec": {
      "Verkaufsprodukt": {
        "*": {
          "Produkt": {
            "*": {
              "Elementarprodukt": {
                "*": {
                  "VersichertePerson": {
                    "PartnerID": {
                      "1": {
                        "@(3)": {
                          "ArtID": {
                            "value": "vertragsdetails.versichertePersonen.versicherungssummenOderLeistungen[&6].kennung"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
]

I see, that the null elements comes from the "ArtID" elements without "vaules" but how can I get rid of them?

I tried a '"operation": "shift",' but that deleted also other elements I want to have.

Can somebody help? Thanks!

Upvotes: 0

Views: 103

Answers (1)

SeleniumNewbe
SeleniumNewbe

Reputation: 85

I found a soulotion. I added this to my spec:

 {
   "operation": "shift",
   "spec": {
     "vertragsdetails": {
       "versichertePersonen": {
         "versicherungssummenOderLeistungen": {
           "*": {
             "kennung": {
               "@1": "vertragsdetails.versichertePersonen.versicherungssummenOderLeistungen[]"
             }
           }
         }
         "dataToKeep": "vertragsdetails.versichertePersonen.dataToKeep"
       }
     }
   }
 }

Upvotes: 0

Related Questions