Skip to content

Commit

Permalink
Add square brackets to prefixes with arrayFormat: comma
Browse files Browse the repository at this point in the history
  • Loading branch information
sanex3339 committed Jun 4, 2019
1 parent faeab53 commit f9c7972
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 91 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,15 @@ assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] });

Some people use comma to join array, **qs** can parse it:
```javascript
var arraysOfObjects = qs.parse('a[]=b,c', { comma: true })
assert.deepEqual(arraysOfObjects, { a: ['b', 'c'] })
```
or
```javascript
var arraysOfObjects = qs.parse('a=b,c', { comma: true })
assert.deepEqual(arraysOfObjects, { a: ['b', 'c'] })
```
(_this cannot convert nested objects, such as `a={b:1},{c:d}`_)
(_this cannot convert nested objects, such as `a[]={b:1},{c:d}`_)

### Stringifying

Expand Down Expand Up @@ -356,7 +361,7 @@ qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' })
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' })
// 'a=b&a=c'
qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'comma' })
// 'a=b,c'
// 'a[]=b,c'
```

When objects are stringified, by default they use bracket notation:
Expand Down
Loading

0 comments on commit f9c7972

Please sign in to comment.