Serialize and deserialize Javascript objects into JSON