You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can set specific fields of an object as required in your schema, by adding the field name inside the `required` array in your schema.
80
96
Example:
@@ -95,6 +111,7 @@ const schema = {
95
111
```
96
112
If the object to stringify has not the required field(s), `fast-json-stringify` will throw an error.
97
113
114
+
<aname="missingFields"></a>
98
115
#### Missing fields
99
116
If a field *is present* in the schema (and is not required) but it *is not present* in the object to stringify, `fast-json-stringify` will not write it in the final string.
`fast-json-stringify` supports additional properties as defined inside JSON schema.
177
+
*additionalProperties* must be an object or a boolean, declared in this way: `{ type: 'type' }`.
178
+
*additionalProperties* will work only for the properties that are not explicitly listed in the *properties* and *patternProperties* objects.
179
+
180
+
If *additionalProperties* is not present or is setted to false, every property that is not explicitly listed in the *properties* and *patternProperties* objects, will be ignored, as said in <ahref="#missingFields">Missing fields</a>.
181
+
If *additionalProperties* is setted to *true*, it will be used `fast-safe-stringify` to stringify the additional properties. If you want to achieve maximum performances we strongly encourage you to use a fixed schema where possible.
0 commit comments