javascript - Swap values of keys in JSON array -


this question has answer here:

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; 

jsfiddle


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -