# json-subset

> Determine whether one json object is a subset of another json object

Latest version **1.0.2** (published 2015-10-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install json-subset
pnpm add json-subset
yarn add json-subset
bun add json-subset
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2015-10-12 |
| First published | 2015-10-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Luke Swart |
| Maintainers | lukeswart |
| Keywords | json, subset |

## Links

- npm: https://www.npmjs.com/package/json-subset
- Repository: https://github.com/LukeSwart/json-subset
- Issues: https://github.com/LukeSwart/json-subset/issues
- npm.io page: https://npm.io/package/json-subset

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.2 (latest) — 2015-10-12
- 1.0.1 — 2015-10-12
- 1.0.0 — 2015-10-12

## README

## json-subset
return whether one json object is a subset of another json object

uses a recursive depth-first-search algorithm to compare for equality across depth levels.

Equality is checked using the `toString()` representation of each leaf node. Objects are recursively checked.

NOTE: This can be very expensive for deep json objects.

## installation
    npm install json-subset

## jsonSubset(a,b)
returns a boolean indicating whether json `a` is a subset of `b`

## usage
```javascript
var subset = require('json-subset')

console.log(subset(
  { a: 'a' },
  { a: 'a', b: 'b' }
))

console.log(subset(
  { a: 'a', b: 'b' },
  { a: 'a' }
))
```
output
```javascript
true
false
```

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