I have a json like as follow
[{
"name": "abc",
"Path": "i.abc",
"count": 5347,
"subFolders": []
},
{
"name": "cde",
"Path": "i.cde",
"count": 0,
"subFolders": [{
"name": "efg",
"Path": "",
"count": 0,
"subFolders": []
},
{
"name": "hij",
"Path": "i.hij",
"count": 1,
"subFolders": []
}]
}]
I want to change "count" value based on "path"(its unique) value. For example I want to change count as 2 for path "i.hij" like that. Following is the code i have tried.
var json = "above json";
for (i=0; i < json.length; i++) {
this.updateJson(json[i], path, count);
}
updateJson: function(json, path, count) {
if (json.path == path) {
json.count = count;
return json;
}
if (json.subFolders != null && json.subFolders.length > 0) {
for(j=0; j < json.subFolders.length; j++) {
this.updateJson(json.subFolders[j], path, count);
}
}
}
How do i get the whole json with modified value?