jquery - How do I update specific key value of the local storage array? -


i have local storage array below

pageitems  = {"stationid":"145","categoryid":"-1","pickupdate":"2014-04-22","pickuptime":"08:00","returndate":"2014-04-23","returntime":"08:00","milage":"false","miles":"","attributes":[[],[]],"additionals":[[],[]]} 

i need update categoryid value 65

pageitems  = {"stationid":"145","categoryid":"65","pickupdate":"2014-04-22","pickuptime":"08:00","returndate":"2014-04-23","returntime":"08:00","milage":"false","miles":"","attributes":[[],[]],"additionals":[[],[]]} 

you can use following;

var pageitems  = '{"stationid":"145","categoryid":"-1","pickupdate":"2014-04-22","pickuptime":"08:00","returndate":"2014-04-23","returntime":"08:00","milage":"false","miles":"","attributes":[[],[]],"additionals":[[],[]]}';  var json = json.parse(pageitems);  json.categoryid = 65;  pageitems_v2 = json.stringify(json); 

here working demo : demo


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -