GithubHelp home page GithubHelp logo

js-pointer's Introduction

js-pointer

Tiny, spec compliant implementation of the JSON Pointer spec RFC 6901 with 100% test coverage and no dependencies.

Getting started

Install via NPM

  npm i js-pointer --save

Point to object properties

const jsPointer = require('js-pointer');

const object = { one: { two: 3 } }
jsPointer.get(object, '/one/two')
// → 3

Pointing to array elements

const object = { one: { two: [3] } }
jsPointer.get(object, '/one/two/0')
// → 3

Pointing through array elements

const object = { one: { two: [{ three: 4 }] } }
jsPointer.get(object, '/one/two/0/three')
// → 4

Please see the spec and tests for further detail of the JSON pointer format.

API

jsPointer.get(object, pointer)

Returns sub-object or value in object referred to by pointer. If pointer does not refer to an object or value then undefined will be returned.

object

Plain object targeted by the pointer

pointer

string JSON pointer. A pointer beginning with # indicates a URI fragment, which will be URI decoded before processing.

js-pointer's People

Contributors

toboid avatar greenkeeper[bot] avatar greenkeeperio-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.