File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,28 @@ const obj = {
163163console .
log (
stringify (obj))
// '{"mail":"[email protected] "}'164164```
165165
166+ <a name =" defaults " ></a >
167+ #### Defaults
168+ ` fast-json-stringify ` supports ` default ` jsonschema key in order to serialize a value
169+ if it is ` undefined ` or not present.
170+
171+ Example:
172+ ``` javascript
173+ const stringify = fastJson ({
174+ title: ' Example Schema' ,
175+ type: ' object' ,
176+ properties: {
177+ nickname: {
178+ type: ' string' ,
179+ default: ' the default string'
180+ }
181+ }
182+ })
183+
184+ console .log (stringify ({})) // '{"nickname":"the default string"}'
185+ console .log (stringify ({nickname: ' my-nickname' })) // '{"nickname":"my-nickname"}'
186+ ```
187+
166188<a name =" patternProperties " ></a >
167189#### Pattern properties
168190` fast-json-stringify ` supports pattern properties as defined by JSON schema.
You can’t perform that action at this time.
0 commit comments