Reputation: 374
I am storing json data into cookie and getting from the cookie.
I am adding data into a json object
x[grapObj.toString()]=graphic;
I am taking the first value for timebeing as x[0] which gives the previous one. The graphics will contain collection of several objects. Storing into cookie
$.cookie('Grap0',JSON.stringify(x[0]),1);
Getting data from cookie
var json123=$.cookie('Grap0');
When this is done object is seen as [object object] Now i try to parse but it throwing exception
Parsing the json
var obj12 = JSON.parse(json123);
var obj12 = $.parseJSON(json123);
I tried both the ways but nothing worked
Upvotes: 0
Views: 75
Reputation: 119847
Cookies store stuff in strings. If the plugin returned json123
is an [object Object]
, then it could have already been parsed! You might have forgot about setting it to do so.
Upvotes: 1