# json-schema-empty-arrays

> ![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

Latest version **1.0.1** (published 2023-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-schema-empty-arrays
pnpm add json-schema-empty-arrays
yarn add json-schema-empty-arrays
bun add json-schema-empty-arrays
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-02-28 |
| First published | 2021-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 3 |
| Unpacked size | 20.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dr. Maximillian Dornseif |
| Maintainers | mdornseif |

## Links

- npm: https://www.npmjs.com/package/json-schema-empty-arrays
- Repository: https://github.com/mdornseif/json-schema-empty-arrays
- Issues: https://github.com/mdornseif/json-schema-empty-arrays/issues
- npm.io page: https://npm.io/package/json-schema-empty-arrays

## Dependencies (3)

- [json-schema](https://npm.io/package/json-schema.md) ^0.4.0
- [json-schema-traverse](https://npm.io/package/json-schema-traverse.md) ^1.0.0
- [@json-schema-tools/traverse](https://npm.io/package/@json-schema-tools/traverse.md) ^1.10.1

## Recent versions

- 1.0.1 (latest) — 2023-02-28
- 1.0.0 — 2021-12-20

## README

![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/mdornseif/json-schema-empty-arrays)](https://github.com/mdornseif/json-schema-empty-arrays)

# json-schema-empty-arrays

Set [] for all missing arrays.

Generate empty arrays for all [JSON-Schema](https://json-schema.org) array properties.

For a given schema `jsonEmptyArrays()` generates an object containing `[]` for all properties of `type: array`.

The output can easily [merged](https://www.npmjs.com/package/lodash.merge) with your existing data to get empty strings instead of missing properties.

```js
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:

- [json-schema-empty-strings](https://www.npmjs.com/package/json-schema-empty-strings)
- [json-schema-default](https://www.npmjs.com/package/json-schema-default)
- [json-schema-empty](https://www.npmjs.com/package/json-schema-empty)

---
_Source: https://npm.io/package/json-schema-empty-arrays · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
