# @hyperjump/json

> JSON parser and stringifier with JSON Pointer support

Latest version **0.2.1** (published 2023-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hyperjump/json
pnpm add @hyperjump/json
yarn add @hyperjump/json
bun add @hyperjump/json
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2023-01-23 |
| First published | 2022-08-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Jason Desrosiers |
| Maintainers | jason.desrosiers |
| Keywords | JSON, parse, parser, stringify, JSON Pointer, reviver, replacer |

## Links

- npm: https://www.npmjs.com/package/@hyperjump/json
- Repository: https://github.com/hyperjump-io/json
- Homepage: https://github.com/hyperjump-io/json#readme
- Issues: https://github.com/hyperjump-io/json/issues
- Funding: https://github.com/sponsors/jdesrosiers
- npm.io page: https://npm.io/package/@hyperjump/json

## Dependencies (2)

- [moo](https://npm.io/package/moo.md) ^0.5.1
- [@hyperjump/json-pointer](https://npm.io/package/@hyperjump/json-pointer.md) ^1.0.1

## 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

- 0.2.1 (latest) — 2023-01-23
- 0.2.0 — 2023-01-19
- 0.1.0 — 2022-08-16
- 0.0.1 — 2022-08-16

## README

Json
====

This is a reimplementation of the builtin `JSON` object to add JSON Pointer
parameters to the "reviver" and "replacer" functions. Other than the added
parameters, the interface and behavior is the same as the original.

Installation
------------
Includes support for node.js (ES Modules, TypeScript) and browsers.

```bash
npm install @hyperjump/json
```

Usage
-----

```javascript
import * as Json from "@hyperjump/json";

const subject = `{
  "type": "object",
  "properties": {
    "foo": { "type": "string" },
    "bar": { "$ref": "#/$defs/number" }
  },
  "required": ["foo", "bar"],

  "$defs": {
    "number": { "type": "number" }
  }
}`;
const result = Json.parse(subject, (key, value, pointer) => {
  console.log("REVIVER", pointer, key, JSON.stringify(value));
  return value;
});

const json = Json.stringify(result, (key, value, pointer) => {
  console.log("REPLACER", pointer, key, value);
  return value;
}, "  ");
```

Contributing
------------

### Tests

Run the tests

```bash
npm test
```

Run the tests with a continuous test runner
```bash
npm test -- --watch
```

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