I have one JSON object:
var myObject = [ { "Name" : "app1", "id" : "1", "groups" : [ { "id" : "test1", "name" : "test group 1", "desc" : "this is a test group" }, { "id" : "test2", "name" : "test group 2", "desc" : "this is another test group" } ] }, { "Name" : "app2", "id" : "2", "groups" : [ { "id" : "test3", "name" : "test group 4", "desc" : "this is a test group" }, { "id" : "test4", "name" : "test group 4", "desc" : "this is another test group" } ] }, { "Name" : "app3", "id" : "3", "groups" : [ { "id" : "test5", "name" : "test group 5", "desc" : "this is a test group" }, { "id" : "test6", "name" : "test group 6", "desc" : "this is another test group" } ] } ];
I have a new value available for "name" for a specific "id". How to replace the "name" of a specific "id" inside any object?
And how to calculate the total number of groups among all objects?
for example: replace the name with "test grp45" for id = "test1"
Here is the fiddle http://jsfiddle.net/qLTB7/21/
source share