I have a json string that needs to be parsed in a specific way. The structure of the json is as follows:
{ "a": [{
"b": [
["c"],
[]
], "d": [
[],
[]
], "e": [
[],
["f"]
], "g": [
[],
["h", "i"]
]
}] }
My current code for parsing and iterating through the keys and values is not giving me the desired output. I am getting some unexpected numbers as keys, which are likely the index numbers of empty values. How can I modify this pure javascript code to only get "a,b,c,d,e,f,g,h,i" as keys and their respective values?
var jsonData = JSON.parse("name");
for (var key in jsonData) {
if (jsonData.hasOwnProperty(key)) {
// do stuff
}
}