json-rel
🔗 Transparent references in JSON
json-rel
converges the following standards and libraries in order to help normalize JSON reference/relationship descriptors:
- JsonPath
- Specification: http://goessner.net/articles/JsonPath/
- Library: https://www.npmjs.com/package/jsonpath
- JsonPointer
- JsonQuery
The goal is to increase developer transparency and to provide a unified, semantic interface for working with related JSON data.
Aside from being all around simple, json-rel
spares library developers from having to:
- decide between which reference specifications(s) to support in your projects
- write an interface for when more than one standard needs support
- bottleneck integrators of your library into a certain specificaton
- write a mechanism that provides a consistent return format (e.g. array vs. element)
Installation
npm install json-rel
Usage
This example shows how to use the main feature of json-rel
, which is being able to provide any relationship or reference string to $
, an "operator" which will automatically identify the correct specification to use based on the relation itself:
const data = foo: bar: true let query = // truelet path = // truelet pointer = // true
If you want to be slightly more concise:
let query = // truelet path = // truelet pointer = // true
You may also, of course, access and use each specification individually:
// true // true // true
You can also infer the specification directly from the relation itself via which
:
// -> json-query // -> json-path // -> json-pointer