@types/jsonpath
- Version 0.2.0
- Published
- No dependencies
- MIT license
Install
npm i @types/jsonpath
yarn add @types/jsonpath
pnpm add @types/jsonpath
Overview
TypeScript definitions for jsonpath
Index
Functions
Type Aliases
Functions
function apply
apply: ( obj: any, pathExpression: string, fn: (x: any) => any) => { path: PathComponent[]; value: any }[];
Runs the supplied function
fn
on each matching element, and replaces each matching element with the return value from the function. The function accepts the value of the matching element as its only parameter. Returns matching nodes with their updated values.
function nodes
nodes: ( obj: any, pathExpression: string, count?: number) => { path: PathComponent[]; value: any }[];
Find elements and their corresponding paths in
obj
matchingpathExpression
. Returns an array of node objects where each node has apath
containing an array of keys representing the location withinobj
, and avalue
pointing to the matched element. Returns only firstcount
nodes if specified.
function parent
parent: (obj: any, pathExpression: string) => any;
Returns the parent of the first matching element.
function parse
parse: (pathExpression: string) => any[];
Parse the provided JSONPath expression into path components and their associated operations.
function paths
paths: (obj: any, pathExpression: string, count?: number) => PathComponent[][];
Find paths to elements in
obj
matchingpathExpression
. Returns an array of element paths that satisfy the provided JSONPath expression. Each path is itself an array of keys representing the location withinobj
of the matching element. Returns only firstcount
paths if specified.
function query
query: (obj: any, pathExpression: string, count?: number) => any[];
Find elements in
obj
matchingpathExpression
. Returns an array of elements that satisfy the provided JSONPath expression,or an empty array if none were matched. Returns only firstcount
elements if specified.
function stringify
stringify: (path: PathComponent[]) => string;
Returns a path expression in string form, given a path. The supplied path may either be a flat array of keys, as returned by
jp.nodes
for example, or may alternatively be a fully parsed path expression in the form of an array of path components as returned byjp.parse
.
function value
value: { (obj: any, pathExpression: string): any; <T>(obj: any, pathExpression: string, newValue: T): T;};
Returns the value of the first element matching
pathExpression
. IfnewValue
is provided, sets the value of the first matching element and returns the new value.
Type Aliases
type PathComponent
type PathComponent = string | number;
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/jsonpath
.
- Markdown[](https://www.jsdocs.io/package/@types/jsonpath)
- HTML<a href="https://www.jsdocs.io/package/@types/jsonpath"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3980 ms. - Missing or incorrect documentation? Open an issue for this package.