
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
json-ref-parser
Advanced tools
Extremely light weight way to resolve jsonschema '$ref' references & inheritance: create circular/graphs, fractals from json (browser/coffeescript/javascript).
Extremely light weight way to resolve jsonschema '$ref' references & inheritance: create circular/graphs, fractals from json (browser/coffeescript/javascript).
Stop processing json tree-structures, think json references and extentions.
nodejs:
jref = require('json-ref-parser')
When referencing to keys, always use underscores. Not doing this will not resolve references correctly.
| Feature | Notation |
|---|---|
| resolving (old) jsonschema references to 'id'-fields | "$ref": "foobar" |
| resolving (new) jsonschema internal jsonpointers | "$ref": "#/foo/value" |
| resolving positional jsonpointers | "$ref": "#/foo/bar[2]" |
| resolving grouped jsonpointers | "$ref": [{"$ref": "#/foo"},{"$ref": "#/bar}] for building jsongraphs |
| evaluating positional jsonpointer function | "$ref": "#/foo/bar()" |
| resolving local files | "$ref": "/some/path/test.json" |
| resolving remote json(schema) files | "$ref": "http://foo.com/person.json" |
| resolving remote jsonpointers | "$ref": "http://foo.com/person.json#/address/street" |
| evaluating jsonpointer notation in string | foo_{#/a/graph/value} |
| evaluating dot-notation in string | foo_{a.graph.value} |
Developer tools:
| Feature | Howto |
|---|---|
| console.log debug output | jref.debug = true |
| redefine ref token | jref.reftoken = '@ref' |
| redefine extend token | jref.extendtoken = '@extend' |
| redefine jsonpointer starttoken | jref.pathtoken = '#' |
| redefine resolve tokens | jref.resolvetoken = '@res' |
NOTE: re-defining tokens is useful to prevent resolving only certain references. A possible rule of thumb could be to have '$ref' references for serverside, and '@ref' references for clientside when resolving the same jsondata.
json = {
foo: {
id: 'foobar',
value: 'bar'
},
example: {
'$ref': 'foobar'
}
};
outputs:
{
foo: { id: 'foobar', value: 'bar' },
example: {
'$ref': 'foobar',
'$res': { value: 'bar' }
}
{
foo: {
value: 'bar',
foo: 'flop'
},
example: {
ids: {
'$ref': '#/foo/foo'
}
}
}
outputs:
{
foo: {
value: 'bar',
foo: 'flop'
},
example: {
ids: {
'$ref': '#/foo/foo',
'$res': 'flop'
}
}
}
NOTE: escaping slashes in keys is supported.
"#/model/foo['\\/bar']/flop"will try to referencemodel.foo['/bar'].flopfrom itself
{
foo: {
"$ref": "http://json-schema.org/address"
}
bar: {
"$ref": "http://json-schema.org/address#/street/number"
}
}
outputs: replaces value of foo with jsonresult from given url, also supports jsonpointers to remote source
NOTE: please install like so for remote support: 'npm install json-ref-lite sync-request'
{
foo: {
"$ref": "./test.json"
}
}
outputs: replaces value of foo with contents of file test.json (use './' for current directory).
{
"bar": ["one","two"],
"foo": { "$ref": "#/bar[1]" }
}
outputs:
{
"bar": ["one","two"],
"foo": {
"$ref": "#/bar[1]",
'$res': "two"
}
}
Ofcoarse functions fall outside the json scope, but they can be executed after binding them to the json.
json = {
"bar": { "$ref": "#/foo()" }
}
json.foo = function(){ return "Hello World"; }
outputs:
{
"bar": {
"$ref": "#/foo()",
'$res': "Hello World"
}
}
FAQs
Extremely light weight way to resolve jsonschema '$ref' references & inheritance: create circular/graphs, fractals from json (browser/coffeescript/javascript).
We found that json-ref-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.