What are you trying to accomplish by doing this? If you just need to save and load state, you can make life much easier on yourself by using localStorage. Is your game multiplayer? If not, save yourself the trouble of managing state on your server and leave it on the client. Here’s a quick way to accomplish this (from StackOverflow):
var testObject = { 'one': 1, 'two': 2, 'three': 3 };
// Put the object into storage
localStorage.setItem('testObject', JSON.stringify(testObject));
// Retrieve the object from storage
var retrievedObject = localStorage.getItem('testObject');
console.log('retrievedObject: ', JSON.parse(retrievedObject));