@@ -21,11 +21,18 @@ Serialization uses
2121[ ` URLSearchParams.toString() ` ] ( https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/toString#return_value )
2222which encodes most non-alphanumeric characters.
2323
24- - The primitive types ` string ` , ` number ` , and ` bigint ` are serialized using ` .toString() ` .
25- - The primitive ` boolean ` type is serialized using ` .toString() ` to ` 'true' ` or ` 'false' ` .
24+ Serialization is guaranteed to be well-defined within each type, i.e.,
25+ if the type of value for a given key in the query string is fixed and known by
26+ the consumer parsing the string, it can be unambigously parsed back to the original primitive value.
27+
28+ - The primitive type ` string ` is serialized using ` .toString() ` .
29+ - The primitive ` number ` and ` bigint ` types are serialized using ` .toString() ` .
30+ - The primitive ` boolean ` type is serialized using ` .toString() ` ,
31+ e.g., ` { foo: true, bar: false } ` serializes to ` foo=true&bar=false ` .
2632- The primitive ` null ` and ` undefined ` values are removed,
2733 e.g., ` { foo: null, bar: undefined, baz: 1 } ` serializes to ` baz=1 ` .
28- - ` Date ` objects are detected and serialized using ` Date.toISOString() ` .
34+ - ` Date ` objects are detected and serialized using ` Date.toISOString() ` ,
35+ e.g., ` { foo: new Date(0) } ` serializes to ` foo=1970-01-01T00%3A00%3A00.000Z ` .
2936- ` Temporal.Instant ` objects are detected and serialized by first converting them to ` Date `
3037 and then serializing the ` Date ` as above.
3138- Arrays are serialized using
@@ -34,12 +41,20 @@ which encodes most non-alphanumeric characters.
3441 - The array ` { foo: [1, 2] } ` serializes to ` foo=1&foo=2 ` .
3542 - The single element array ` { foo: [1] } ` serializes to ` foo=1 ` .
3643 - The empty array ` { foo: [] } ` serializes to ` foo= ` .
37- - Serialization of the single element array containing the empty string is not supported
38- and will throw an ` UnserializableParamError ` .
44+ - Serialization of arrays containing ` null ` or ` undefined ` values
45+ is not supported and will throw an ` UnserializableParamError ` .
46+ - Serialization of the single element array containing the empty string
47+ is not supported and will throw an ` UnserializableParamError ` .
3948 Otherwise, the serialization of ` { foo: [''] } ` would conflict with ` { foo: [] } ` .
4049 This serializer chooses to support the more common and more useful case of an empty array.
41- - Serialization of functions or other objects is not supported
42- and will throw an ` UnserializableParamError ` .
50+ - Serialization of objects and nested objects first serializes the keys
51+ to dot-path format and then serializes the values as above, e.g.,
52+ ` { foo: 'a', bar: { baz: 'b', fizz: [1, 2] } } ` serializes to
53+ ` foo=a&bar.baz=b&bar.fizz=1&bar.fizz=2 ` .
54+ - Serialization of nested arrays or objects nested inside arrays
55+ is not supported and will throw an ` UnserializableParamError ` .
56+ - Serialization of functions or other objects is
57+ is not supported and will throw an ` UnserializableParamError ` .
4358
4459## Installation
4560
0 commit comments