Filtered JSON from an XML



I have an XML file like below .


<animals> <dog> <name>Rufus</name> <breed>labrador</breed> </dog> <dog> <name>Marty</name> <breed>whippet</breed> </dog> <cat name="Matilda"/> </animals>


And i need the output to be a filtered JSON . I got the XML converted to JSON with Jackson Library.



{
animals:{
dog:[{name:'Rufus',breed:'Labrador'},
{name:'Marty',breed:'whippet'}],
cat:{name:'Matilda'}
}
}


But i need a formatted output , with selected nodes. Is there some jar which takes filters . say if give an exclude filter as



animals.dog=true


I get an output like the below



{
animals:{
cat:{name:'Matilda'}
}
}

No comments:

Post a Comment