0
我正在嘗試使Express REST API正常工作,並且出於某種原因,JSON正文總是以不必要的引號結尾。我使用下面的配置,快遞中間件:Express req.body用引號
app.use(bodyParse.urlencoded({
extended: true
}));
app.use(bodyParser.json());
而且現在用
console.log(JSON.stringify(req.body));
爲了測試這一點。隨着請求主體
{"name": "New Event", "description": "Hello. This is event"}
我得到
{"{\"name\": \"New Event Thingy\", \"description\": \"Hello. This is event\"}":""}
,並用身體
"name": "New Event", "description": "Hello. This is event"
我得到
{"\"name\": \"New Event Thingy\", \"description\": \"Hello. This is event\"":""}
爲什麼會出現這些不必要的字符?
修復它。謝謝! – aftrumpet 2014-09-20 02:43:00