I have a bunch of json files that I need to read and save as a text file. The problem is the names of the keys in each json file differs. I've seen the use of the function Object.keys to obtain the key names, but, for example, in such a file:
{
"mainKey1" :
[
{
"subKey1" : "Value 1",
"subKey2" : "Value 2",
"subKey3" : "Value 3"
},
{
"subKey1" : "Value 1",
"subKey2" : "Value 2",
"subKey3" : "Value 3"
}
],
"mainKey2" :
[
{
"subKey1" : "Value 1",
"subKey2" : "Value 2",
"subKey3" : "Value 3"
},
{
"subKey1" : "Value 1",
"subKey2" : "Value 2",
"subKey3" : "Value 3"
}
]
}
How could I get the names "mainKey1","mainKey2", and so on, and also "subKey1", subKey2", and so on.
Finally, after obtaining these key names, how could I use them to read the corresponding "Value1", "Value2", "Value3".
Thanks in advance!