Node json request badly parsed

I have the following service:

var bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }))

var new_log = function(req, res){
    console.log("REQ:n" + JSON.stringify(req.body));
    res.end();
}

and trying with curl: curl.exe -X POST -d '{"holder_name":"34cbfb95"}' http://MY_SERVER:8550/api/new-log/

and the printed object in console is {"'{holder_name:34cbfb95}'":""} Like it doesn't know its already json

If I put -H "Accept: application/json" it's the same and if I put -H "Content-Type: application/json" it just says unexpected token ' if I remove the single quotes from the command it says unexpected token h

链接地址: http://www.djcxy.com/p/48614.html

上一篇: Powershell卷曲双引号

下一篇: 节点json请求严重分析