node.js c++模块怎样使用json
1个回答
展开全部
使用node.js生成json数据代码如下:
var http = require('http');
var data = {key: 'value', hello: 'world'};
var srv = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify(data));
});
srv.listen(8080, function() {
console.log('listening on localhost:8080');
});
var http = require('http');
var data = {key: 'value', hello: 'world'};
var srv = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify(data));
});
srv.listen(8080, function() {
console.log('listening on localhost:8080');
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询