https://github.com/hyperjump-io/json
A JSON parser and stringifier with JSON Pointer support
https://github.com/hyperjump-io/json
Last synced: 5 months ago
JSON representation
A JSON parser and stringifier with JSON Pointer support
- Host: GitHub
- URL: https://github.com/hyperjump-io/json
- Owner: hyperjump-io
- License: mit
- Created: 2022-08-12T00:31:15.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-11T20:08:03.000Z (almost 2 years ago)
- Last Synced: 2025-10-11T21:16:03.244Z (8 months ago)
- Language: JavaScript
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
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
```