I need to Dynamically parse the mongodb json documents and write to file. so i have tried by writing java routine to parse the below json using JsonFlattener which is not giving the required output shared below.
Please can any one help me . How to extract dynamically columns from json documents and write in below target format
Source :
{
"name": "sample",
"def": [
{
"setId": 1,
"setDef": [
{
"name": "ABC1",
"type": "STRING"
},
{
"name": "XYZ1",
"type": "STRING"
}
]
},
{
"setId": 2,
"setDef": [
{
"name": "abc2",
"type": "STRING"
},
{
"name": "xyz2",
"type": "STRING"
}
]
}
]
}
required format(Target):
name;setID;setDef_name;setDef_type
sample;1;ABC1;STRING
sample;1;XYZ1;STRING
sample;2;abc2;STRING
sample;2;xyz2;STRING
Getting below format with JsonFlattener which is not matching requirement.