https://github.com/seesharpsoft/lazy-json-ref
Provides a lazy/late and transparent resolution of references in JSON.
https://github.com/seesharpsoft/lazy-json-ref
javascript json json-reference lazy-loading typescript
Last synced: 7 months ago
JSON representation
Provides a lazy/late and transparent resolution of references in JSON.
- Host: GitHub
- URL: https://github.com/seesharpsoft/lazy-json-ref
- Owner: SeeSharpSoft
- License: apache-2.0
- Created: 2020-02-08T06:42:18.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T06:49:15.000Z (about 3 years ago)
- Last Synced: 2025-04-02T13:41:14.851Z (11 months ago)
- Topics: javascript, json, json-reference, lazy-loading, typescript
- Language: TypeScript
- Homepage:
- Size: 495 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# lazy-json-ref
Provide resolution of references in JSON (https://tools.ietf.org/id/draft-pbryan-zyp-json-ref-03.html) in a lazy and transparent manner.
**Example:**
pets.json
```
{
"definitions": {
"pet": {
"type": "object",
"properties": {
"name": { "type": "string" },
"breed": { "type": "string" },
"age": { "type": "string" }
},
"required": ["name", "breed", "age"]
}
},
"type": "object",
"properties": {
"cat": { "$ref": "#/definitions/pet" },
"dog": { "$ref": "#/definitions/pet" }
}
}
```
```
let json = LazyJson.create("/test/specs/definitions/pets.json"); // argument can also be a json object itself
json.properties.cat.required
> ["name", "breed", "age"]
json.properties.dog.type
> "object"
```
**What's special about it?**
The reference is resolved lazy on request (**not** in `LazyJson.create`) without any additional function call or de-reference handling. Works also with referencing .json files.
Further examples can be found [here](https://github.com/SeeSharpSoft/lazy-json-ref/tree/master/test/specs/definitions).
**Disclaimer**
This is a first draft (or PoC so to say) - feedback welcome!