var obj = {
"name": "LiLi",
"age": 22,
"sex": "F"
}
var str = JSON.stringify(obj)
console.log(str)
var obj2 = JSON.parse(str)
console.log(obj2)
执行:node demo-json.js
通过http模块获取一个数据值,如下:http.request(options,function(res){
console.log('Status:'+res.statusCode)
//console.log('Headers:'+JSON.stringify(res.headers))
console.log(res.body)
res.on('data',function(chunk){
...
})
res.on('end',function(){
console.log('发送完毕')
})
})
options配置:
var options = {
host:'www.123.com',
port:80,
path:'/course/AjaxCourseMembers?ids='+ids,
method:'GET',
headers:{
'Accept':'*/*',
'Accept-Encoding':'gzip, deflate, sdch',
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)