Skip to content
Advertisement

convert nested object to csv where all parents of lowest properties are visible on individual lines

I have a nested object that I want to to transform to flat lines. Below is the object:

JavaScript

I want to be able to see it like this, where the top level of the nest is always visible for each line:

JavaScript

I know how to loop through arrays to do this, but I’m not sure how to achieve it with a nested object. I’ve searched s/o, but haven’t seen anything that quite achieves this. (My actual data set is much longer) Any help is very welcome. Thank you.

Advertisement

Answer

Just perform a loop at each level of your structure:

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