I want to load multiple .json files to an array, but I don't know the exact amount of files.
E.g.:
(in: .../example-folder)
abc.json
xyz.json
uvw.json
array.length == 3
(in .../example_folder)
abc.json
xyz.json
array.length == 2
How could I do that in javascript? Thanks in advance!
Kind regards,
Soxxes
Edit: Normally I am doing it this way:
function loadJSON(url, callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType('application/json');
xobj.open('GET', url, true);
xobj.onreadystatechange = function() {
if (xobj.readyState == 4 && xobj.status == '200') {
callback(xobj.responseText);
}
};
xobj.send(null);
}
loadJSON("../example_folder/abc.json", function(res){
data_parsed = JSON.parse(res);
data_stringified = JSON.stringify(data_parsed, null, 4);
abc = data_stringified;
});