Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
json-locator
Advanced tools
Because all the good names (json-query, json-select, etc) were all taken up, I'm forced to use this name.
Essentially a thin wrapper around the excellent jsonpath
library. The JSONPath specification is sketchy (I mean look at that website, 2007?) and not many people use it, but I needed something that would refer to specific nodes or groups of nodes.
var locator = require('json-locator');
var data = {
colors: [
{ type: 'additive', name: 'red', red: 255, green: 0, blue: 0 },
{ type: 'additive', name: 'green', red: 0, green: 255, blue: 0 },
{ type: 'additive', name: 'blue', red: 0, green: 0, blue: 255 },
{ type: 'subtractive', name: 'cyan', red: 0, green: 255, blue: 255 },
{ type: 'subtractive', name: 'magenta', red: 255, green: 0, blue: 255 },
{ type: 'subtractive', name: 'yellow', red: 255, green: 255, blue: 0 },
{ type: 'subtractive', name: 'black', red: 0, green: 0, blue: 0 }
]
};
locator.transform('colors[type="subtractive"][red<100]');
// expected colors[?(@.type=="subtractive" && @.red<100)]
locator.query(data, 'colors[type="subtractive"][red<100]');
// expected [ { ... name: 'cyan' ...}, { ... name: 'black' ...} ]
The npm module jsonpath has an excellent implementation and looks well maintained but:
==
instead of =
and boolean operators like &&
.@
syntax which is unnecessary 99% of the time.I wanted to filter something like:
"inputs": [
{
"type": "dropdown",
"data": {
"name": "Memory",
"hasPricing": true,
"hasFrequency": false,
"options": [
{
"name": "one",
"price": "23",
"frequency": ""
},
{
"name": "two",
"price": "99",
"frequency": ""
}
]
}
}
]
with an expression such as
inputs[type="dropdown"][data.hasPricing].data.options[*].price
and get back
["23", "99"]
and not have to use an expression like
inputs[?(@.type=="dropdown" && @.data.hasPricing)].data.options[*].price
FAQs
Wrapper around jsonpath module
The npm package json-locator receives a total of 4 weekly downloads. As such, json-locator popularity was classified as not popular.
We found that json-locator 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.