Imagine having a deeply nested object with an unknown structure until runtime, like:
{
"row-0" : {
"rec-0" : {
"date" : 20220121,
"tags" : [ "val-0" ]
},
"rec-1" : {
"date" : 20220116,
"url" : "https://example.com/a",
"tags" : [ "val-0", "val-1" ]
}
},
"row-1" : {
"rec-0" : {
"date" : 20220116,
"url" : "https://example.com/b"
}
}
}
I am seeking a tool or program that can transform this into a tabular (2D) format such as:
{
"row-0" : {
"['rec-0']['date']" : 20220121,
"['rec-0']['tags'][0]" : "val-0",
"['rec-1']['date']" : 20220116,
"['rec-1']['url']" : "https://example.com/a",
"['rec-1']['tags'][0]" : "val-0",
"['rec-1']['tags'][1]" : "val-1"
},
"row-1" : {
"['rec-0']['date']" : 20220116,
"['rec-0']['url'']" : "https://example.com/b"
}
}
This conversion allows for easy exporting as CSV and editing in a spreadsheet application. The keys represent the paths of the original nested object to aid in undoing the transformation.
What would be the most effective way to accomplish this task?