1.0.1 • Published 1 year ago

json-schema-empty-arrays v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

NPM License NPM Version Last Commit

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);

See also: