Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
json-pointer
Advanced tools
Readme
Some utilities for JSON pointers described by RFC 6901
Provides some additional stuff i needed but is not included in node-jsonpointer
$ npm install json-pointer
$ component install manuelstofer/json-pointer
var pointer = require('json-pointer');
Convenience wrapper around the api.
Calls .get
when called with an object
and a pointer
.
Calls .set
when also called with value
.
If only object
is supplied, it returns a partially applied function, mapped to the object.
var obj = {
existing: 'bla'
};
pointer(obj, '/new-value/bla', 'expected'); // .set a property
var objPointer = pointer(obj); // all api calls are now scoped to `obj`
objPointer('/existing') // gets '/existing' from `obj`
objPointer('/new-value/bla') // gets '/new-value/bla' from `obj`
The wrapper supports chainable object oriented style.
var obj = {anything: 'bla'};
var objPointer = pointer(obj);
objPointer.set('/example', 'bla').dict();
Looks up a JSON pointer in an object.
var obj = {
example: {
bla: 'hello'
}
};
pointer.get(obj, '/example/bla');
Sets a new value on object at the location described by pointer.
var obj = {};
pointer.set(obj, '/example/bla', 'hello');
Removes an attribute of object referenced by pointer
var obj = {
example: 'hello'
};
pointer.remove(obj, '/example');
// obj -> {}
Creates a dictionary object (pointer -> value).
var obj = {
hello: {bla: 'example'}
};
pointer.dict(obj);
// Returns:
// {
// '/hello/bla': 'example'
// }
Just like:
each(pointer.dict(obj), iterator);
Tests if an object has a value for a JSON pointer.
var obj = {
bla: 'hello'
};
pointer.has(obj, '/bla'); // -> true
pointer.has(obj, '/non/existing'); // -> false
Escapes a reference token.
pointer.escape('hello~bla'); // -> 'hello~0bla'
pointer.escape('hello/bla'); // -> 'hello~1bla'
Unescape a reference token.
pointer.unescape('hello~0bla'); // -> 'hello~bla'
pointer.unescape('hello~1bla'); // -> 'hello/bla'
Converts a JSON pointer into an array of reference tokens.
pointer.parse('/hello/bla'); // -> ['hello', 'bla']
Builds a json pointer from an array of reference tokens.
pointer.compile(['hello', 'bla']); // -> '/hello/bla'
FAQs
Some utilities for JSON pointers described by RFC 6901
We found that json-pointer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).