Express正文解析器无法正确解析对象

时间:2019-07-17 00:04:16

标签: node.js express body-parser

当我使用

app.use(express.json());
app.use(express.urlencoded({extended: true}));

然后客户发布了此信息:

form:
{
    permission: {'45': 'asdf'},
    project_id: '98293949-c650-46d9-8bdb-fc57fb30fd88',
    task_id: '86325d50-7813-40ae-a8f9-7ddaf3f1790d',
    user_id: 'uvjKMSB0euYrCy45XhmpuQEQaZF2'
} 

当我console.log req.body时

res.send('the api is working'+JSON.stringify(req.body),);
  

{“ permission”:[“ asdf”],“ project_id”:“ 98293949-c650-46d9-8bdb-fc57fb30fd88”,“ task_id”:“ 86325d50-7813-40ae-a8f9-7ddaf3f1790d”,“ user_id”: “ uvjKMSB0euYrCy45XhmpuQEQaZF2”}

为什么在字段权限处的正文请求是“ permission”:[“ asdf”] 而不是 {'45':'asdf'}

>

0 个答案:

没有答案