Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
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.
@finnair/path-parser
Advanced tools
@finnair/path-parser
contains nearley.js based parsers for Path
and PathMatcher
.
See @finnair/path
or instructions on how to use Path
and PathMatcher
.
Install v-validation using yarn
:
yarn add @finnair/path-parser
Or npm
:
npm install @finnair/path-parser
import { parsePath } from '@finnair/path-parser';
parsePath(`$.array[1]["\\"property\\" with spaces and 'quotes'"]`); // JSON string encoded in brackets!
// Path.of('array', 1, `"property" with spaces and 'quotes'`);
// Single quotes also work, but encoding is still JSON string so the value cannot contain ' character
parsePath(`$['single quotes']`); // Path.of('single quotes')
parsePath(`$['single\'quote']`); // Fail!
// ...without using unicode escape
parsePath(`$['\\u0027']`); // Path.of("'");
parsePathMatcher
parses simple JsonPath like expressions. Supported expressions are
Expression | Description |
---|---|
$.property | Identifiers matching RegExp /^[a-zA-Z_][a-zA-Z0-9_]*$/ |
$[0] | Index match |
$.* | Any property matcher, wildcard (matches also array indexes) |
$[*] | Any index matcher, wildcard (matches only array indexes) |
$["JSON string encoded property"] | Property as JSON encoded string |
$['JSON string encoded property'] | Property as single quoted, but otherwise JSON encoded, string(*) |
$[union,"of",4,'components'] | Union matcher that also supports identifiers and JSON encoded strings |
*) This is the official way of JsonPath
, but the specification is a bit unclear on the encoding. In this library we prefer proper JSON string encoding with double quotes.
import { parsePathMatcher } from '@finnair/path-parser';
parsePathMatcher(`$.array[0][*].*['union',"of",properties,1]`);
// PathMatcher.of(
// 'array',
// 0,
// AnyIndex,
// AnyProperty,
// UnionMatcher.of('union', 'of', 'properties', 1)
// )
FAQs
Simple object path as array of strings and numbers
The npm package @finnair/path-parser receives a total of 0 weekly downloads. As such, @finnair/path-parser popularity was classified as not popular.
We found that @finnair/path-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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
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.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.