cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Removing Null Values from JSON

manchis
New Contributor

Hi,

We have a requirement to remove the null values elements from the json. Below is the example JSON which is having null values at Root and child levels. We need a solution to remove nulls at all levels and if all elements in child are removed then the entire child should get remove.

Could you please provide the pipeline solution for it.

Example:
{
โ€œRootโ€:{
โ€œElement1โ€:โ€œ1โ€,
โ€œElement2โ€:โ€œAโ€,
โ€œElement3โ€:null,

โ€œChild1โ€:{
โ€œElement4โ€:โ€œ1โ€,
โ€œElement5โ€:null
}

โ€œChild2โ€:{
โ€œElement6โ€:โ€œ1โ€,
โ€œChild3โ€:{
โ€œElement7โ€:โ€œ1โ€,
โ€œElement8โ€:null,
โ€œChild4โ€:{
โ€œElement9โ€: null
}
}
}
}
}

Expected Result:

{
โ€œRootโ€:{
โ€œElement1โ€:โ€œ1โ€,
โ€œElement2โ€:โ€œAโ€

โ€œChild1โ€:{
โ€œElement4โ€:โ€œ1โ€
}

โ€œChild2โ€:{
โ€œElement6โ€:โ€œ1โ€,
โ€œChild3โ€:{
โ€œElement7โ€:โ€œ1โ€
}
}
}
}

2 REPLIES 2

SpiroTaleski
Valued Contributor

@manchis

I think that the expression from the below post will help you to achieve the desired output:

Regards,
Spiro Taleski

manchis
New Contributor

@Spiro_Taleski - Thank you! Yes I checked this article and it worked.