Serialization of Javascript from Server(NodeJS) to Browser
I would like to serialize an instance of JS object from the Server-side to the 开发者_如何转开发Client side (the object contains data members and functions)
I have a Javascript stack on both end, all my users use Chrome and My server side is a NodeJS impl..
how would I do it? It should be trivial as my server is a Javascript one..
You could send it as JSON string. Here's an example:
response.writeHead(200, {'Content-Type': 'application/json'});
response.write(JSON.stringify(yourObject));
response.close();
精彩评论