I wanted to store the object in local storage and I serialized the object using JSON.stringify. Then some of the inner attributes are missing after parse using JSON.parse.
I attached 2 images below to see the changes and appreciate it if anyone can answer a better solution for this. Thanks.
This object is just before stringified using JSON.
This object is stringified and parse using JSON
This is how i store and retreive data
Json.Stringify does not pass functions into the stringified JSON, i.e. functions will not be copied into the string as functions are not valid JSON objects. In your case, the difficulty is a function and as such won't be copied.
You can include the function by using a replacer:
JSON.stringify({
/* your object here */
}, function(key, val) {
return (typeof val === 'function') ? '' + val : val;
});