Skip to content

Provides a lazy/late and transparent resolution of references in JSON.

License

Notifications You must be signed in to change notification settings

SeeSharpSoft/lazy-json-ref

Folders and files

NameName
Last commit message
Last commit date
Feb 11, 2020
Feb 10, 2020
Feb 11, 2020
Feb 9, 2020
Feb 9, 2020
Feb 8, 2020
Feb 13, 2020
Feb 9, 2020
Sep 11, 2020
Feb 14, 2020
Feb 9, 2020

Repository files navigation

Node.js CI

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.

Disclaimer

This is a first draft (or PoC so to say) - feedback welcome!

About

Provides a lazy/late and transparent resolution of references in JSON.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published