@@ -196,6 +196,38 @@ change the behavior when duplicate keys are encountered
196196 qs.DecodeOptions(duplicates = qs.Duplicates.LAST ),
197197 ) == {' foo' : ' baz' }
198198
199+ Bracket-array keys always combine, regardless of the duplicate strategy:
200+
201+ .. code :: python
202+
203+ import qs_codec as qs
204+
205+ assert qs.decode(
206+ ' a=1&a=2&b[]=1&b[]=2' ,
207+ qs.DecodeOptions(duplicates = qs.Duplicates.LAST ),
208+ ) == {' a' : ' 2' , ' b' : [' 1' , ' 2' ]}
209+
210+ When a key appears as both an object and a scalar,
211+ :py:attr: `strict_merge <qs_codec.models.decode_options.DecodeOptions.strict_merge> ` wraps the conflicting values in a
212+ ``list `` by default:
213+
214+ .. code :: python
215+
216+ import qs_codec as qs
217+
218+ assert qs.decode(' a[b]=c&a=d' ) == {' a' : [{' b' : ' c' }, ' d' ]}
219+
220+ Set ``strict_merge `` to ``False `` to restore the legacy behavior, where non-empty string scalars become object keys:
221+
222+ .. code :: python
223+
224+ import qs_codec as qs
225+
226+ assert qs.decode(
227+ ' a[b]=c&a=d' ,
228+ qs.DecodeOptions(strict_merge = False ),
229+ ) == {' a' : {' b' : ' c' , ' d' : True }}
230+
199231 If you have to deal with legacy browsers or services, there’s also
200232support for decoding percent-encoded octets as :py:attr: `LATIN1 <qs_codec.enums.charset.Charset.LATIN1> `:
201233
@@ -310,11 +342,11 @@ Note that an empty ``str``\ing is also a value and will be preserved:
310342 assert qs.decode(' a[0]=b&a[1]=&a[2]=c' ) == {' a' : [' b' , ' ' , ' c' ]}
311343
312344:py:attr: `decode <qs_codec.decode> ` will also limit specifying indices
313- in a ``list `` to a maximum index of ``20 ``. Any ``list `` members with an
314- index of greater than `` 20 `` will instead be converted to a `` dict `` with
315- the index as the key. This is needed to handle cases when someone sent,
316- for example, ``a[999999999] `` and it will take significant time to iterate
317- over this huge ``list ``.
345+ in a ``list `` to a maximum element count of ``20 ``. Index ``19 `` is the
346+ last index that can create a default `` list ``; index `` 20 `` and higher
347+ are converted to a `` dict `` with the index as the key. This is needed to
348+ handle cases when someone sent, for example, ``a[999999999] `` and it
349+ would take significant time to iterate over this huge ``list ``.
318350
319351.. code :: python
320352
0 commit comments