I'm working with a JSON of the following structure:
data = [ { "tests": [ { "test_status": "Passed", "test_name": "test1", "subtests": [ { "subtest_status": "Passed", "subtest_name": "echo" }, { "subtest_status": "Passed", "subtest_name": "sleep" }, { "subtest_status": "Passed", "subtest_name": "run" } ], "full_path": "path1" }, { "test_status": "Failed", "test_name": "test2", "subtests": [ { "subtest_status": "Passed", "subtest_name": "echo" }, { "subtest_status": "Passed", "subtest_name": "exec" }, { "subtest_status": "Failed", "subtest_name": "check" } ], "full_path": "path2" } ], "main_name": "main_test1" }, { "tests": [ { "test_status": "Passed", "test_name": "test3", "subtests": [ { "subtest_status": "Passed", "subtest_name": "prepare" }, { "subtest_status": "Passed", "subtest_name": "run" }, { "subtest_status": "Passed", "subtest_name": "check" } ], "full_path": "path3" } ], "main_name": "main_test2 } ] I'm trying to figure out the best way to convert it into a CSV format:
main_name,full_path,test_name,test_status,subtest_name,subtest_status,subtest_name,subtest_status,... The wanted result for this example:
main_test1,path1,test1,Passed,echo,Passed,sleep,Passed,run,Passed main_test1,path2,test2,Failed,echo,Passed,exec,Passed,check,Failed main_test2,path3,test3,Passed,prepare,Passed,run,Passed,check,Passed A quick web search I found a few Vue modules I could use but they all are quite new and I'm not sure if it is wise to depend on them. I was wondering if someone already came across with this issue and could suggest a way to achieve this CSV structure. The plan is to make a button list that the user can choose which of the CSV columns he wants to be included in his report so if possible, please show a way that I can insert if statements (for example if user chooses to show main_name). Our tool is written in Vue but we could use any JS solution. How can I achieve this goal? What is the best way to solve this problem?