Licence
MIT
Version
1.0.1
Deps
3
Size
21 kB
Vulns
0
Weekly
0
json-schema-empty-arrays
Set [] for all missing arrays.
Generate empty arrays for all JSON-Schema array properties.
For a given schema jsonEmptyArrays() generates an object containing [] for all properties of type: array.
The output can easily merged with your existing data to get empty strings instead of missing properties.
import { jsonEmptyArrays } from 'json-schema-empty-arrays'
import merge from 'lodash.merge'
// carve! merge polbaby handles arrays differently than you think
const finalData = merge({}, jsonEmptyArrays(schema), inputData)