A problem about x-www-form-urlencoded
sunyongjian opened this issue · comments
JoYous-SUN commented
my code
const bodyparser = require('koa-bodyparser');
const json = require('koa-json');
app.use(bodyparser({
enableTypes:['json', 'form', 'text']
}));
app.use(json());
//router
router.post('/abc', async (ctx) => {
console.log(ctx.request.body, 'body');
ctx.body = ctx.request.body;
});
when i request '/abc':
content-type is application/x-www-form-urlencoded
request-body
data[template_col][p_price_value][taxes_by_distance_serial_interval][intervals][0][begin]: 0
then ctx.request.body is:
{
"data": {
"template_col": {
"p_price_value": {
"taxes_by_distance_serial_interval": {
"intervals": [
{
"[begin]": "1"
}
]
}
}
}
}
}
why not
"intervals": [
{ "begin": "1" }
]
But expressjs/bodyparser is okay...
JoYous-SUN commented
resolve:
app.use(bodyparser({
enableTypes:['json', 'form', 'text'],
queryString: {
depth: Infinity
}
}));