manuelstofer / json-pointer Goto Github PK
View Code? Open in Web Editor NEWSome utilities for the JSON pointers described by RFC 6901
License: MIT License
Some utilities for the JSON pointers described by RFC 6901
License: MIT License
I believe it should return the empty string instead.
parse()
behaves correctly:
var jsonPointer = require('json-pointer');
jsonPointer.parse(''); // []
jsonPointer.parse('/'); // ['']
But they don't match up:
jsonPointer.compile(jsonPointer.parse('')) !== '';
jsp = require "json-pointer"
console.dir jsp.has { a: "x", b: [] }, "/b"
console.dir jsp.dict { a: "x", b: [] }
returns:
true
{ '/a': 'x' }
Very nice implementation, clean, useful methods, well documented.
I was wondering if you had a license in mind because I'd like to copy this code into my client side google closure library and tweak it to match the style and namespacing there, if it'd be OK. I would of course leave a comment in the file back to this repo as the original source.
It should return the whole object.
@manuelstofer what do you think?
Or you prefer that users just try/catch?
+--------------+------------------+----------+-------------------+---------------+---------------------------------------+
| LIBRARY | VULNERABILITY ID | SEVERITY | INSTALLED VERSION | FIXED VERSION | TITLE |
+--------------+------------------+----------+-------------------+---------------+---------------------------------------+
| json-pointer | CVE-2021-23820 | CRITICAL | 0.6.1 | | Prototype Pollution in json-pointer |
| | | | | | -->avd.aquasec.com/nvd/cve-2021-23820 |
+--------------+------------------+----------+-------------------+---------------+---------------------------------------+
Hey
it seem like json-pointer can't handle arrays inside objects very well. Using the dict
method, it produces an error when trying to replace array keys.
var pointer = require('json-pointer');
var obj = {
bla : {
bli : [4, 5, 6]
}
};
console.log(pointer.dict(obj));
I got the following error:
/tmp/pntr/node_modules/json-pointer/index.js:143
return str.replace(/~/g, '~0').replace(/\//g, '~1');
^
TypeError: Object 0 has no method 'replace'
at escape (/tmp/pntr/node_modules/json-pointer/index.js:143:16)
at Array.map (native)
at Function.compile (/tmp/pntr/node_modules/json-pointer/index.js:175:28)
at mapObj (/tmp/pntr/node_modules/json-pointer/index.js:101:29)
at /tmp/pntr/node_modules/json-pointer/index.js:96:21
at forEach (/tmp/pntr/node_modules/json-pointer/node_modules/foreach/index.js:12:16)
at mapObj (/tmp/pntr/node_modules/json-pointer/index.js:94:17)
at /tmp/pntr/node_modules/json-pointer/index.js:96:21
at forEach (/tmp/pntr/node_modules/json-pointer/node_modules/foreach/index.js:17:20)
at mapObj (/tmp/pntr/node_modules/json-pointer/index.js:94:17)
Pointer arguments should be called Selectors, to remove ambiguity between the method and the arguments.
Also on readme/documentation, would be nice to list the rules of these selectors, so we know how to query and what possibilities we have
Hi - I just started using your library for something, and I realised I can get()
, and I can set()
, but I'd like to be able to remove()
.
Any chance of putting that in?
There's some odd whitespace in line 130 that happens to work fine in Node but breaks when run in the browser via browserify.
The builds would be much faster. It just needs sudo: false
in .travis.yml file.
Unless there are some reasons not to...
https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01
I have an implementation here. https://github.com/mokkabonna/json-hyper-schema/blob/master/src/relative-json-pointer.js complete with tests: https://github.com/mokkabonna/json-hyper-schema/blob/master/test/specs/relative-json-pointer.spec.js
Would you be willing to implement that in this library? If so I can make a PR.
If not I will publish my implementation as a separate library. I anyway depend on your implementation.
Heya @manuelstofer, just came across this today:
https://nvd.nist.gov/vuln/detail/CVE-2021-23820
Looks like there might still be a security vulnerability. Thought I'd bring it up.
Can you improve the documentation and add what exceptions are thrown and why?
For example if you use get with a non existing reference token, the function will throw an Error the a message saying "Invalid reference token: foo".
It's too bad I have to browse the code or the unit tests to figure out what is the basic behavior of the functions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.