Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

json-rel

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-rel

Transparent references in JSON

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

json-rel

:link: Transparent references in JSON


json-rel converges the following standards and libraries in order to help normalize JSON reference/relationsip descriptors:

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:

  1. decide between which reference specifications(s) to support in your projects
  2. write an interface for when more than one standard needs support
  3. bottleneck integrators of your library into a certain specificaton
  4. 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:

import $ from 'json-rel'

const data = {
  foo: {
    bar: true
  }
}

let query   = $('foo.bar').use(data).get()   // true
let path    = $('$.foo.bar').use(data).get() // true
let pointer = $('/foo/bar').use(data).get()  // true

If you want to be slightly more concise:

let query   = $('foo[bar]', data).get()  // true
let path    = $('$.foo.bar', data).get() // true
let pointer = $('/foo/bar', data).get()  // true

You may also, of course, access and use each specification individually:

import query from 'json-rel'
import path from 'json-rel'
import pointer from 'json-rel'

let query1   = query('foo[bar]', data).get()   // true
let path2    = path('$.foo.bar', data).get()   // true
let pointer2 = pointer('/foo/bar', data).get() // true

You can also infer the specification directly from the relation itself via which:

import which from 'json-rel'

which('foo[bar]')  // -> json-query
which('$.foo.bar') // -> json-path
which('/foo/bar')  // -> json-pointer

Keywords

FAQs

Package last updated on 23 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc