【发布时间】:2015-08-13 22:25:18
【问题描述】:
我有一个处理 JSON 的函数。它由路由处理程序调用。该函数不是获取 JSON 字符串,而是获取 this-
{"type": "Buffer", "data": [123,122,22,....]}
因此,我无法解析 JSON。是什么导致了这个问题?
我正在传递 JSON,例如 -
{"id": "123", "username": "abc",...}
我的代码是 -
server.post('/pages', restify.jsonBodyParser(),createPage);
function createPage(req, res, next)
{
myfunction(req,res);
next();
}
function myfunction(req,res){
console.log(req);
}
这是请求头 -
{"authorization":"Basic xxxxxxx","accept":"application/json, application/xml, text/json, text/x-json, text/javascript, text/xml","user-agent":"RestSharp/105.0.1.0","content-type":"Application/Json", "host":"remoteserver.com:xxx","cookie":"sessionid=36yTgWtzpSR4VrvRikTEzfu8wBcPLWTQARtLgT63","content-length":"4246","accept-encoding":"gzip, deflate"}
【问题讨论】: