ljharb/qs

Cannot parse array of objects using arrayFormat = 'brackets'

Open

#215 创建于 2017年6月13日

在 GitHub 查看
 (13 评论) (11 反应) (0 负责人)JavaScript (744 fork)batch import
bughelp wantedparse

仓库指标

Star
 (8,015 star)
PR 合并指标
 (平均合并 6天 22小时) (30 天内合并 2 个 PR)

描述

The README states:

You can also create arrays of objects:

var arraysOfObjects = qs.parse('a[][b]=c');
assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] });

However when you try to parse an array with 2 objects, an object with 2 keys is created instead:

var arraysOfObjects = qs.parse('a[][b]=c&a[][d]=e');
assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' , d: 'e'}] });

This also happens with arrayFormat = 'repeat'.

If arrays without indices cannot be supported, may the allowDots option could affect arrays instead: (a.0.b=c&a.1.d=e)

贡献者指南