ljharb/qs

Cannot parse array of objects using arrayFormat = 'brackets'

Ouverte

#215 ouverte le 13 juin 2017

 (13 commentaires) (11 réactions) (0 personne assignée)JavaScript (902 forks)batch import
bughelp wantedparse

Métriques du dépôt

Stars
 (8 943 étoiles)
Métriques de merge PR
 (Merge moyen 6j 22h) (2 PRs mergées en 30 j)

Description

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)

Guide contributeur