You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The depth limit mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number.
74
81
75
-
### Arrays
82
+
### Parsing Arrays
76
83
77
84
**qs** can also parse arrays using a similar `[]` notation:
78
85
@@ -127,3 +134,37 @@ You can also create arrays of objects:
127
134
Qs.parse('a[][b]=c');
128
135
// { a: [{ b: 'c' }] }
129
136
```
137
+
138
+
### Stringifying
139
+
140
+
When stringifying, **qs** always URI encodes output. Objects are stringified as you would expect:
141
+
142
+
```javascript
143
+
Qs.stringify({ a:'b' });
144
+
// 'a=b'
145
+
Qs.stringify({ a: { b:'c' } });
146
+
// 'a%5Bb%5D=c'
147
+
```
148
+
149
+
Examples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases *will* be URI encoded during real usage.
150
+
151
+
When arrays are stringified, they are always given explicit indices:
152
+
153
+
```javascript
154
+
Qs.stringify({ a: ['b', 'c', 'd'] });
155
+
// 'a[0]=b&a[1]=c&a[2]=d'
156
+
```
157
+
158
+
Empty strings and null values will omit the value, but the equals sign (=) remains in place:
159
+
160
+
```javascript
161
+
Qs.stringify({ a:'' });
162
+
// 'a='
163
+
```
164
+
165
+
Properties that are set to `undefined` will be omitted entirely:
0 commit comments