{
"特效1": [{
"特效1_1": ["AttackArrow.json", "icon_effect1.json"]
},
{
"特效1_2": ["effec_thudun.json"]
}
}
The object data structure is similar to this. When I know the file name AttackArrow.json, I want to get the special effect 1/special effect 1_1 through this file name. How to get it
Equivalent to when I click on the file AttackArrow.json, I want to know which folder it is in
欧阳克2017-06-28 09:30:20
Modify your data structure and see if it is the result you want.
var obj = {"arr": [{"id": ["AttackArrow.json", "icon_effect1.json"]},{"id": ["effec_thudun.json"]}]}
function func(obj){
for(i=0;i<obj.arr.length;i++){
for(j=0;j<obj.arr[i].id.length;j++){
if(obj.arr[i].id[j] == "AttackArrow.json"){
return i,j
}
}
}
}
func(obj);
console.log(i,j)
阿神2017-06-28 09:30:20
You can record the key set by adding an attribute to the target node when traversing the output