开发者

Serialization of Javascript from Server(NodeJS) to Browser

开发者 https://www.devze.com 2023-01-09 13:59 出处:网络
I would like to serialize an instance of JS object from the Server-side to the 开发者_如何转开发Client side

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();
0

精彩评论

暂无评论...
验证码 换一张
取 消