Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Json Jolt to Remove All Nulls from Json

avatar
Super Guru

Hi,

 

I have the following Json. I would like to create a Jolt Spec to remove all nulls from all levels. How can I do that? Any help would be appreciated. Thanks

{
"ID": "c22b657e-227b-4c65-e6f8-08d88a3e1118",
"Name": "SomeName",
"TaggedItemName": "SomeValue",
"ITRName": "SomeValue",
"TestReference": null,
"JobCardName": null,
"Comments": "test",
"PrimaryHandoverName": null,
"SecondaryHandoverNumber": null,
"CertificationGroupingName": null,
"DocumentCode": "SomeValue",
"AssignedToName": "SomeName",
"DocumentReference": null,
"TagITRCompletionStatusName": "Rejected",
"ScheduleRevision": null,
"Completed": {
"SignOff_AuthP": "John",
"SignOff_Date": null
},
"Accepted": {
"SignOff_AuthP": "Smith",
"SignOff_Date": null
},
"Approved": {
"SignOff_AuthP": "Ali",
"SignOff_Date": null
},
"ScheduleGroup": null,
"DownloadUri": "SomeUrl",
"UpdatedDate": "2022-01-18T11:36:33.9057626Z",
"CreatedDate": "2020-11-30T10:57:20.8534287Z"
}

1 ACCEPTED SOLUTION

avatar
Super Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login
3 REPLIES 3

avatar
Super Guru

I don't know if it's possible to do this generically and recursively using Jolt.

Nevertheless, if your schema is well know you can achieve want you want with something like this:

{
"Completed": {
"*": {
"*": {
"@1": "&3.&2"
}
}
},
"Accepted": {
"*": {
"*": {
"@1": "&3.&2"
}
}
},
"Approved": {
"*": {
"*": {
"@1": "&3.&2"
}
}
},
"*": {
"*": {
"@1": "&2"
}
}
}

 

Cheers,

Andre

--
Was your question answered? Please take some time to click on "Accept as Solution" below this post.
If you find a reply useful, say thanks by clicking on the thumbs up button.

avatar
Super Guru

Thank you so much,

 

That did the trick. You seem to be a json jolt guru. Im trying to understand it myself but its not that straight forward. Can you just elaborate this syntax for me which remove null values on the base level:

"*": {
"*": {
"@1": "&2"
}
}

Why there is two asterisks in front of it?

avatar
Super Guru
hide-solution

This problem has been solved!

Want to get a detailed solution you have to login/registered on the community

Register/Login