@@ -77,7 +77,31 @@ let value = JsonURL.parse( "(Hello:Address Bar!!)", { AQF: true });
7777let string = JsonURL .stringify ( value, { AQF : true } );
7878```
7979
80- There are additional options available, but that's all you need to get started.
80+ ### Options - noEmptyComposite
81+
82+ The JSON→URL specification defines the empty composite value, ` () ` , because an
83+ empty array is indistinguishable from an empty object. This works well in
84+ practice, generally, but it can lead to counterintuitive results when parsing
85+ JSON→URL text into a language-native object and then stringifying it back
86+ into JSON→URL text; the input text doesn't "round-trip" back to
87+ itself as expected.
88+
89+ The ` noEmptyComposite ` parse option causes the character sequence ` () ` to be
90+ parsed as an empty array, and the character sequence ` (:) ` to be parsed as an
91+ empty object. And the ` noEmptyComposite ` stringify option instructs
92+ ` stringify ` to generate those strings appropriately.
93+
94+ [ ![ RunKit: noEmptyComposite] ( https://img.shields.io/badge/RunKit-noEmptyComposite-ff69b4 )] [ runkit3 ]
95+
96+ ``` js
97+ let value = JsonURL .parse ( " (Array:(true,false,(nested),()),Object:(nested:(:)))" , { AQF : true , noEmptyComposite: true });
98+ let string = JsonURL .stringify ( value, { AQF : true , noEmptyComposite: true });
99+ ```
100+
101+ ### Options - More
102+
103+ There are additional options available. The [ typescript definition] [ dts ] file
104+ is a good place to learn more.
81105
82106JSON→URL has no runtime dependencies.
83107
@@ -100,6 +124,10 @@ set by default.
100124
101125[ runkit2 ] : https://runkit.com/jsonurl/hello-aqf
102126
127+ [ runkit3 ] : https://runkit.com/jsonurl/noemptycomposite
128+
129+ [ dts ] : https://github.com/jsonurl/jsonurl-js/blob/main/jsonurl.d.ts
130+
103131## License
104132
105133[ ![ FOSSA Status] ( https://app.fossa.com/api/projects/git%2Bgithub.com%2Fjsonurl%2Fjsonurl-js.svg?type=large )] ( https://app.fossa.com/projects/git%2Bgithub.com%2Fjsonurl%2Fjsonurl-js?ref=badge_large )
0 commit comments