File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,28 @@ const obj = {
163
163
console .
log (
stringify (obj))
// '{"mail":"[email protected] "}'
164
164
```
165
165
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
+
166
188
<a name =" patternProperties " ></a >
167
189
#### Pattern properties
168
190
` fast-json-stringify ` supports pattern properties as defined by JSON schema.
You can’t perform that action at this time.
0 commit comments