In my Json data, I have a nested structure of folders and files. My goal is to determine the number of files in a specific folder and its sub-folders based on the folder's ID. Below is an example of the JSON dataset:
var jsonStr = {
"hierarchy": {
"date": "2014/09/24 15:21:23",
"folder": {
"name": "Root",
"id": "Root",
"file": [{
"id": "22U2621210__PIN_検査報告書Ver1.0_20140923162232.xls"
}, {
"id": "C22-1(EU仕様)_20140923162409.xlsx"
}, {
"id": "Machine_Inspection_20140923162329.xlsx"
}],
"folder": {
"name": "Level-1",
"id": "1411396172645",
"file": {
"id": "22U2621210__PIN_検査報告書Ver1.0_20140923162232.xls"
},
"folder": {
"name": "123",
"id": "1411538469568",
"file": [{
"id": "C22-1(EU仕様)_20140923162409.xlsx"
}, {
"id": "Machine_Inspection_20140923162329.xlsx"
}]
}
}
}
}
};
Each folder has a unique name and ID. If I want to find the number of files within a specific folder and its subfolders by searching with its ID, for instance, if I input the folder "name 123"
and ID "1411538469568"
, it should display only 2 files:
"C22-1(EU仕様)_20140923162409.xlsx"
and "Machine_Inspection_20140923162329.xlsx"
. However, if I provide the folder name "Root"
and ID "Root,"
it should retrieve all file IDs.
I am currently working on this functionality in a JSFiddle: http://jsfiddle.net/ma3kno2o/