json-schema-empty-arrays
v1.0.1
Published
![NPM License](https://img.shields.io/npm/l/json-schema-empty-arrays) [![NPM Version](https://img.shields.io/npm/v/json-schema-empty-arrays)](https://www.npmjs.com/package/json-schema-empty-arrays) [![Last Commit](https://img.shields.io/github/last-commit
Downloads
80
Readme
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);