jquery - Browser local storage get and set json objects issue -
im receiving webservice string has json format. using jquery.parsejson
im creating json object on client side (and can access without issues).
after utilize localstorage.setitem
add together json object browser local storage. issue comes when localstorage.getitem
, [object object]
, dont know how access object json object anymore.
do know whats cause , solution this?
thanks
jose.
you can stringify object before storing it, , later parse when retrieve it:
var testobject = { 'one': 1, 'two': 2, 'three': 3 }; // set object storage localstorage.setitem('testobject', json.stringify(testobject)); //retrieve object , parse 1 time again var retrievedobject = json.parse(localstorage.getitem('testobject'));
jquery json
No comments:
Post a Comment