I am importing a nested JSON file and would like to be able to display the data extracted from the JSON file as a table.
How can I go through the different levels of this JSON file and be able to display specific data I need (example I would only like to display the inner most data).
Also, how can I access the children of nodes that have spaces on their key?
Here is a sample JSON file:
{
"1234567ABCD123": [{
"1111": {
"File 1 Data Goes Here": {
"AA": {
"Some more data": {
"AAAA": [{
"Data List": {
"01": {
"File Name": {
"FN": "Hello"
},
"Author": {
"A1": "John Doe"
}
}
}
}
]
}
}
}
}
}
],
"7654321ABCD321": [{
"2222": {
"File 2 Data Goes Here": {
"BB": {
"Data List": {
"File Name": "Hello Again"
}
}
}
}
}, {
"3333": {
"File 3 Data Goes Here": {
"CC": {
"Data List1": {
"File Name": "Hello Again 2"
},
"Data List2": {
"File Name": "Hello Again 3"
},
"Data List3": {
"File Name": "Hello Again 4"
}
}
}
}
}
]
}
And here is my vue method snippet:
changeViaUpload(ev) {
const file = ev.target.files[0];
const reader = new FileReader();
var vm = this;
reader.onload = function(e) {
vm.msg = "[" + e.target.result + "]";
vm.show = true;
vm.parsedJson = JSON.parse(vm.msg);
console.log(vm.parsedJson);
vm.parsedJson.forEach(function(item) {
console.log("Outermost Data: " + item["1234567ABCD123"]);
});
};
reader.readAsText(file);
}
CodeSanboxLink: https://codesandbox.io/s/vue-quasar-template-enfjp
Thanks!