Skip to content
Advertisement

Convert JSOn object into a flat JSON Array

I have a nested JSON object that getting from a mongoDB query that i would like to convert into flat JSON array .I am using nested mondo documents, but i would like to show the data in a more readble way. My JSON has the following structure:

JavaScript

I want to show only the important information and not the structure of the nested array. How i can modify my data in Javascript on order to achieve the following result.

JavaScript

I have tried to do in this way but it´s not working.

JavaScript

Advertisement

Answer

I believe this will perform the transformation you seek:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement