javascript - Swap values of keys in JSON array -
this question has answer here:
- swap value of 2 properties on object(s) 2 answers
i have following json. need swap sortid
like have this,
[{"categoryid":1,"name":"worktable","sortid":1} ,{"categoryid":2,"name":"bf ","sortid":2}]
after swaping 'sortid' need
[{"categoryid":1,"name":"worktable","sortid":2} ,{"categoryid":2,"name":"bf ","sortid":1}]
please tell me how through javascript.
var tmp = a[0].sortid; a[0].sortid = a[1].sortid; a[1].sortid = tmp;
Comments
Post a Comment