Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
samsameta10
Contributor
Contributor

MongoDB JSON documents dynamically parsing

Team,

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.

format:

name;setID;setDef_name;setDef_type

sample;1;ABC1;STRING;XYZ1;STRING

sample;2;abc2;STRING;xyz2;STRING

Thanks in advance

Labels (3)
0 Replies