how to modify a json array with jQuery
Posted
by Emin
on Stack Overflow
See other posts from Stack Overflow
or by Emin
Published on 2010-05-18T21:52:54Z
Indexed on
2010/05/18
22:00 UTC
Read the original article
Hit count: 251
I have the following json array of objects in my code
var groups = [
{ "gid": 28, "name": "Group 1", "ishidden": false, "isprivate": false },
{ "gid": 16, "name": "Group 2", "ishidden": true, "isprivate": false },
{ "gid": 31, "name": "Group 3", "ishidden": true, "isprivate": false },
{ "gid": 11, "name": "Group 4", "ishidden": false, "isprivate": false },
{ "gid": 23, "name": "Group 5", "ishidden": false, "isprivate": false }
];
I can access or iterate through this with no problm using jQuery. However a situation arose where I need to change a value of one of the items (e.g. change the ishidden
property to true
for gid: 28
) and then run some other jQuery function against it. Is this possible? or do I have to re-build the whole object ? If possible, how can I achieve this?
any help would be appreciated!
© Stack Overflow or respective owner