Using nested JSON objects in MongoDB to create reports

Hello Helical Insight,

I am using Helical Insight 4.0. I have connected to MongoDB via Apache Drill. I am able to see the collections and objects. However, I need help to view the data within a nested JSON object. What are the options available and how to use them?

Thank You,
Sesa.

Hello Sesa,

You can traverse nested JSON objects using the dot (.) notation.

For example, let us say, below is the structure of your JSON object:

obj1:{ obj2:{ obj3:{key1:data1, key2:data2, key3:data3}}}

You want to view data1 from the object. In that case, you will use:

mongo.collectionName.obj1.obj2.obj3.key1

If your data has array of objects, then you can use ‘flatten’ function.

Using DB functions: In the “More” options, you will find under data type – json and nested data.

In these, you will find the functions key-value, flatten, index, key-value-generation. These functions can be applied to the JSON object to achieve the necessary result.

image

Thank You,
Helical Insight.