Node.js / Express POST请求正文parsing为不正确的JSON

我有一个聚合物core-ajax组件发送一些数据到Node.js服务器。 数据正在正确发送(我可以用Go Web服务器parsing它),但是Node将它parsing为string化的正文,它是JSON对象中空白string的关键字:

 { '{"count":-1,"uid":1}': '' } 

这是从聚合物发送请求的代码:

 sendCount: function(change) { console.log("Sending..."); console.log(JSON.stringify({"count": change, "uid": this.uid})); // ^ This prints: {"count":-1,"uid":1} this.$.ajax.body = JSON.stringify({"count": change, "uid": this.uid}); this.$.ajax.go(); } 

这是节点代码:

 app.post("/post", function(req, res) { console.log(res.headers); console.log(req.body); // Prints { '{"count":-1,"uid":1}': '' } res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(req.body)); }); 

当我得到响应返回它已经返回了格式不正确的JSON。

我如何正确parsing节点中的JSON?

也:

 app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); 

设置core-ajax属性contentType="application/json"handleAs="json"然后将JSON设置为ajax.body