I am trying to create a JSON array inside another JSON array.
I think I did it right, but when I call the second array it returns undefined.
JSON file :
var files = [
{"Files" : [
{"file1" : "file1"},
{"file2" : "file2"},
{"file3" : "file3"}
]},
{"Texts" : [
{"file4" : "file4"},
{"file5" : "file5"},
{"file6" : "file6"}
]}
];
When I trying this command it works -
console.log(files[0]); // Works, returns the array
But when I trying this command it not working -
console.log(files[0][1]); // Not working, return undefined
I expect that this will return file2.
What I did wrong ?
EDIT : The script gets JSON file like that from the server, and the script need to loop through the JSON. So think about the names ( Files, Texts, file1, file2 etc.. ) as unknown..