Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

jsonpath-plus

s3u13.6mMIT10.2.0TypeScript support: included

A JS implementation of JSONPath with some additional operators

json, jsonpath

readme

npm

testing badge coverage badge

Known Vulnerabilities

Licenses badge

Node.js CI status

(see also licenses for dev. deps.)

JSONPath Plus

Analyse, transform, and selectively extract data from JSON documents (and JavaScript objects).

jsonpath-plus expands on the original specification to add some additional operators and makes explicit some behaviors the original did not spell out.

Try the browser demo or Runkit (Node).

Please note: This project is not currently being actively maintained. We may accept well-documented PRs or some simple updates, but are not looking to make fixes or add new features ourselves.

Features

  • Compliant with the original jsonpath spec
  • Convenient additions or elaborations not provided in the original spec:
    • ^ for grabbing the parent of a matching item
    • ~ for grabbing property names of matching items (as array)
    • Type selectors for obtaining:
      • Basic JSON types: @null(), @boolean(), @number(), @string(), @array(), @object()
      • @integer()
      • The compound type @scalar() (which also accepts undefined and non-finite numbers when querying JavaScript objects as well as all of the basic non-object/non-function types)
      • @other() usable in conjunction with a user-defined otherTypeCallback
      • Non-JSON types that can nevertheless be used when querying non-JSON JavaScript objects (@undefined(), @function(), @nonFinite())
    • @path/@parent/@property/@parentProperty/@root shorthand selectors within filters
    • Escaping
      • ` for escaping remaining sequence
      • @['...']/?@['...'] syntax for escaping special characters within property names in filters
    • Documents $.. (getting all parent components)
  • ESM and UMD export formats
  • In addition to queried values, can return various meta-information including paths or pointers to the value, as well as the parent object and parent property name (to allow for modification).
  • Utilities for converting between paths, arrays, and pointers
  • Option to prevent evaluations permitted in the original spec or supply a sandbox for evaluated values.
  • Option for callback to handle results as they are obtained.

Benchmarking

jsonpath-plus is consistently performant with both large and small datasets compared to other json querying libraries per json-querying-performance-testing. You can verify these findings by running the project yourself and adding more perf cases.

Install

npm install jsonpath-plus

Setup

Node.js

const {JSONPath} = require('jsonpath-plus');

const result = JSONPath({path: '...', json});

Browser

For browser usage you can directly include dist/index-browser-umd.cjs; no Browserify magic is necessary:

<script src="node_modules/jsonpath-plus/dist/index-browser-umd.cjs"></script>

<script>

const result = JSONPath.JSONPath({path: '...', json: {}});

</script>

ESM (Modern browsers)

You may also use ES6 Module imports (for modern browsers):

<script type="module">

import {
    JSONPath
} from './node_modules/jsonpath-plus/dist/index-browser-esm.js';

const result = JSONPath({path: '...', json: {}});

</script>

ESM (Bundlers)

Or if you are bundling your JavaScript (e.g., with Rollup), just use, noting that mainFields should include browser for browser builds (for Node, the default, which checks module, should be fine):

import {JSONPath} from 'jsonpath-plus';

const result = JSONPath({path: '...', json});

Usage

The full signature available is:

const result = JSONPath([options,] path, json, callback, otherTypeCallback);

The arguments path, json, callback, and otherTypeCallback can alternatively be expressed (along with any other of the available properties) on options.

Note that result will contain all items found (optionally wrapped into an array) whereas callback can be used if you wish to perform some operation as each item is discovered, with the callback function being executed 0 to N times depending on the number of independent items to be found in the result. See the docs below for more on JSONPath's available arguments.

See also the API docs.

Properties

The properties that can be supplied on the options object or evaluate method (as the first argument) include:

  • path (required) - The JSONPath expression as a (normalized or unnormalized) string or array
  • json (required) - The JSON object to evaluate (whether of null, boolean, number, string, object, or array type).
  • autostart (default: true) - If this is supplied as false, one may call the evaluate method manually.
  • flatten (default: false) - Whether the returned array of results will be flattened to a single dimension array.
  • resultType (default: "value") - Can be case-insensitive form of "value", "path", "pointer", "parent", or "parentProperty" to determine respectively whether to return results as the values of the found items, as their absolute paths, as JSON Pointers to the absolute paths, as their parent objects, or as their parent's property name. If set to "all", all of these types will be returned on an object with the type as key name.
  • sandbox (default: {}) - Key-value map of variables to be available to code evaluations such as filtering expressions. (Note that the current path and value will also be available to those expressions; see the Syntax section for details.)
  • wrap (default: true) - Whether or not to wrap the results in an array. If wrap is set to false, and no results are found, undefined will be returned (as opposed to an empty array when wrap is set to true). If wrap is set to false and a single non-array result is found, that result will be the only item returned (not within an array). An array will still be returned if multiple results are found, however. To avoid ambiguities (in the case where it is necessary to distinguish between a result which is a failure and one which is an empty array), it is recommended to switch the default to false.
  • eval (default: "safe") - Script evaluation method. safe: In browser, it will use a minimal scripting engine which doesn't use eval or Function and satisfies Content Security Policy. In NodeJS, it has no effect and is equivalent to native as scripting is safe there. native: uses the native scripting capabilities. i.e. unsafe eval or Function in browser and vm.Script in nodejs. false: Disable JavaScript evaluation expressions and throw exceptions when these expressions are attempted. callback [ (code, context) => value]: A custom implementation which is called with code and context as arguments to return the evaluated value. class: A class which is created with code as constructor argument and code is evaluated by calling runInNewContext with context.
  • ignoreEvalErrors (default: false) - Ignore errors encountered during script evaluation.
  • parent (default: null) - In the event that a query could be made to return the root node, this allows the parent of that root node to be returned within results.
  • parentProperty (default: null) - In the event that a query could be made to return the root node, this allows the parentProperty of that root node to be returned within results.
  • callback (default: (none)) - If supplied, a callback will be called immediately upon retrieval of an end point value. The three arguments supplied will be the value of the payload (according to resultType), the type of the payload (whether it is a normal "value" or a "property" name), and a full payload object (with all resultTypes).
  • otherTypeCallback (default: <A function that throws an error when @other() is encountered>) - In the current absence of JSON Schema support, one can determine types beyond the built-in types by adding the operator @other() at the end of one's query. If such a path is encountered, the otherTypeCallback will be invoked with the value of the item, its path, its parent, and its parent's property name, and it should return a boolean indicating whether the supplied value belongs to the "other" type or not (or it may handle transformations and return false).

Instance methods

  • evaluate(path, json, callback, otherTypeCallback) OR evaluate({path: <path>, json: <json object>, callback: <callback function>, otherTypeCallback: <otherTypeCallback function>}) - This method is only necessary if the autostart property is set to false. It can be used for repeated evaluations using the same configuration. Besides the listed properties, the latter method pattern can accept any of the other allowed instance properties (except for autostart which would have no relevance here).

Class properties and methods

  • JSONPath.cache - Exposes the cache object for those who wish to preserve and reuse it for optimization purposes.
  • JSONPath.toPathArray(pathAsString) - Accepts a normalized or unnormalized path as string and converts to an array: for example, ['$', 'aProperty', 'anotherProperty'].
  • JSONPath.toPathString(pathAsArray) - Accepts a path array and converts to a normalized path string. The string will be in a form like: $['aProperty']['anotherProperty][0]. The JSONPath terminal constructions ~ and ^ and type operators like @string() are silently stripped.
  • JSONPath.toPointer(pathAsArray) - Accepts a path array and converts to a JSON Pointer. The string will be in a form like: /aProperty/anotherProperty/0 (with any ~ and / internal characters escaped as per the JSON Pointer spec). The JSONPath terminal constructions ~ and ^ and type operators like @string() are silently stripped.

Syntax through examples

Given the following JSON, taken from http://goessner.net/articles/JsonPath/:

{
"store": {
  "book": [
    {
      "category": "reference",
      "author": "Nigel Rees",
      "title": "Sayings of the Century",
      "price": 8.95
    },
    {
      "category": "fiction",
      "author": "Evelyn Waugh",
      "title": "Sword of Honour",
      "price": 12.99
    },
    {
      "category": "fiction",
      "author": "Herman Melville",
      "title": "Moby Dick",
      "isbn": "0-553-21311-3",
      "price": 8.99
    },
    {
      "category": "fiction",
      "author": "J. R. R. Tolkien",
      "title": "The Lord of the Rings",
      "isbn": "0-395-19395-8",
      "price": 22.99
    }
  ],
  "bicycle": {
    "color": "red",
    "price": 19.95
  }
}
}

and the following XML representation:

<store>
    <book>
        <category>reference</category>
        <author>Nigel Rees</author>
        <title>Sayings of the Century</title>
        <price>8.95</price>
    </book>
    <book>
        <category>fiction</category>
        <author>Evelyn Waugh</author>
        <title>Sword of Honour</title>
        <price>12.99</price>
    </book>
    <book>
        <category>fiction</category>
        <author>Herman Melville</author>
        <title>Moby Dick</title>
        <isbn>0-553-21311-3</isbn>
        <price>8.99</price>
    </book>
    <book>
        <category>fiction</category>
        <author>J. R. R. Tolkien</author>
        <title>The Lord of the Rings</title>
        <isbn>0-395-19395-8</isbn>
        <price>22.99</price>
    </book>
    <bicycle>
        <color>red</color>
        <price>19.95</price>
    </bicycle>
</store>

Please note that the XPath examples below do not distinguish between retrieving elements and their text content (except where useful for comparisons or to prevent ambiguity). Note: to test the XPath examples (including 2.0 ones), this demo may be helpful (set to xml or xml-strict).

XPath JSONPath Result Notes
/store/book/author $.store.book[*].author The authors of all books in the store Can also be represented without the $. as store.book[*].author (though this is not present in the original spec); note that some character literals ($ and @) require escaping, however
//author $..author All authors
/store/* $.store.* All things in store, which are its books (a book array) and a red bicycle (a bicycle object).
/store//price $.store..price The price of everything in the store.
//book[3] $..book[2] The third book (book object)
//book[last()] $..book[(@.length-1)]
$..book[-1:]
The last book in order. To access a property with a special character, utilize [(@['...'])] for the filter (this particular feature is not present in the original spec)
//book[position()<3] $..book[0,1]
$..book[:2]
The first two books
//book/*[self::category|self::author] or //book/(category,author) in XPath 2.0 $..book[0][category,author] The categories and authors of all books
//book[isbn] $..book[?(@.isbn)] Filter all books with an ISBN number To access a property with a special character, utilize [?@['...']] for the filter (this particular feature is not present in the original spec)
//book[price<10] $..book[?(@.price<10)] Filter all books cheaper than 10
//*[name() = 'price' and . != 8.95] $..*[?(@property === 'price' && @ !== 8.95)] Obtain all property values of objects whose property is price and which does not equal 8.95 With the bare @ allowing filtering objects by property value (not necessarily within arrays), you can add ^ after the expression to get at the object possessing the filtered properties
/ $ The root of the JSON object (i.e., the whole object itself) To get a literal $ (by itself or anywhere in the path), you must use the backtick escape
//*/*|//*/*/text() $..* All Elements (and text) beneath root in an XML document. All members of a JSON structure beneath the root.
//* $.. All Elements in an XML document. All parent components of a JSON structure including root. This behavior was not directly specified in the original spec
//*[price>19]/.. $..[?(@.price>19)]^ Parent of those specific items with a price greater than 19 (i.e., the store value as the parent of the bicycle and the book array as parent of an individual book) Parent (caret) not present in the original spec
/store/*/name() (in XPath 2.0) $.store.*~ The property names of the store sub-object ("book" and "bicycle"). Useful with wildcard properties. Property name (tilde) is not present in the original spec
/store/book[not(. is /store/book[1])] (in XPath 2.0) $.store.book[?(@path !== "$['store']['book'][0]")] All books besides that at the path pointing to the first @path not present in the original spec
//book[parent::*/bicycle/color = "red"]/category $..book[?(@parent.bicycle && @parent.bicycle.color === "red")].category Grabs all categories of books where the parent object of the book has a bicycle child whose color is red (i.e., all the books) @parent is not present in the original spec
//book/*[name() != 'category'] $..book.*[?(@property !== "category")] Grabs all children of "book" except for "category" ones @property is not present in the original spec
//book[position() != 1] $..book[?(@property !== 0)] Grabs all books whose property (which, being that we are reaching inside an array, is the numeric index) is not 0 @property is not present in the original spec
/store/*/*[name(parent::*) != 'book'] $.store.*[?(@parentProperty !== "book")] Grabs the grandchildren of store whose parent property is not book (i.e., bicycle's children, "color" and "price") @parentProperty is not present in the original spec
//book[count(preceding-sibling::*) != 0]/*/text() $..book.*[?(@parentProperty !== 0)] Get the property values of all book instances whereby the parent property of these values (i.e., the array index holding the book item parent object) is not 0 @parentProperty is not present in the original spec
//book[price = /store/book[3]/price] $..book[?(@.price === @root.store.book[2].price)] Filter all books whose price equals the price of the third book @root is not present in the original spec
//book/../*[. instance of element(*, xs:decimal)] (in XPath 2.0) $..book..*@number() Get the numeric values within the book array @number(), the other basic types (@boolean(), @string()), other low-level derived types (@null(), @object(), @array()), the JSONSchema-added type, @integer(), the compound type @scalar() (which also accepts undefined and non-finite numbers for JavaScript objects as well as all of the basic non-object/non-function types), the type, @other(), to be used in conjunction with a user-defined callback (see otherTypeCallback) and the following non-JSON types that can nevertheless be used with JSONPath when querying non-JSON JavaScript objects (@undefined(), @function(), @nonFinite()) are not present in the original spec
//book/*[name() = 'category' and matches(., 'tion$')] (XPath 2.0) $..book.*[?(@property === "category" && @.match(/TION$/i))] All categories of books which match the regex (end in 'TION' case insensitive) @property is not present in the original spec.
//book/[matches(name(), 'bn$')]/parent:: (XPath 2.0) $..book.*[?(@property.match(/bn$/i))]^ All books which have a property matching the regex (end in 'TION' case insensitive) @property is not present in the original spec. Note: Uses the parent selector ^ at the end of the expression to return to the parent object; without the parent selector, it matches the two isbn key values.
| ` (e.g., `$ to match a property literally named $) Escapes the entire sequence following (to be treated as a literal) ` is not present in the original spec; to get a literal backtick, use an additional backtick to escape

Any additional variables supplied as properties on the optional "sandbox" object option are also available to (parenthetical-based) evaluations.

Potential sources of confusion for XPath users

  1. In JSONPath, a filter expression, in addition to its @ being a reference to its children, actually selects the immediate children as well, whereas in XPath, filter conditions do not select the children but delimit which of its parent nodes will be obtained in the result.
  2. In JSONPath, array indexes are, as in JavaScript, 0-based (they begin from 0), whereas in XPath, they are 1-based.
  3. In JSONPath, equality tests utilize (as per JavaScript) multiple equal signs whereas in XPath, they use a single equal sign.

Command line interface

A basic command line interface (CLI) is provided. Access it using npx jsonpath-plus <json-file> <jsonpath-query>.

Ideas

  1. Support OR outside of filters (as in XPath |) and grouping.
  2. Create syntax to work like XPath filters in not selecting children?
  3. Allow option for parentNode equivalent (maintaining entire chain of parent-and-parentProperty objects up to root)

Development

Running the tests on Node:

npm test

For in-browser tests:

  • Serve the js/html files:
npm run browser-test

License

MIT License.

changelog

CHANGES for jsonpath-plus

10.2.0

  • fix(eval): improve security of safe-eval (#233)
  • chore: update deps. and devDeps.

10.1.0

  • feat: add typeof operator to safe script

10.0.7

  • fix(security): prevent constructor access
  • docs: add security policy file

10.0.6

  • fix(security): prevent call/apply invocation of Function

10.0.5

  • fix: remove overly aggressive disabling of native functions but disallow __proto__

10.0.4

  • fix(security): further prevent binding of Function calls which may evade detection

10.0.3

  • fix(security): prevent binding of Function calls which may evade detection

10.0.2

  • fix(security): prevent Function calls outside of member expressions

10.0.1

  • fix(security): prohibit Function in "safe" vm

10.0.0

BREAKING CHANGES:

  • Require Node 18+

  • fix(security): use safe vm by default in Node

  • chore: bump jsep, devDeps. and lint

9.0.0

BREAKING CHANGES:

  • Removes preventEval property. Prefer eval: false instead.
  • Changed behavior of eval property. In the browser, eval/Function won't be used by default to evaluate expressions. Instead, we'll safely evaluate using a subset of JavaScript. To resume using unsafe eval in the browser, pass in the option eval: "native"

  • feat: add safe eval for browser and eval option (#185) (@80avin)

  • feat: add ignoreEvalErrors property (@80avin)

8.1.0

  • feat: add basic cli (#206) (@vid)

8.0.0

  • Breaking change: Bump Node engines to 14
  • feat: add support for nested filter expressions (@carlosingles)
  • docs: update README and license (@akirataguchi115)
  • docs: github workflow badge (@dsanch3z)

7.2.0

  • perf: optimize walk method by 10%-34% (@jacobroschen)
  • chore: add types to exports field (@awlayton)

7.1.0

  • perf: improve evaluation speed of conditional queries (@jacobroschen)

7.0.0

  • Breaking change: Bump engines to 12
  • fix: remove console.log when error is thrown (@sh33dafi)
  • chore: update devDeps.

6.0.1 (2021-07-07)

  • Fix: Some package.json paths needed updating (@matushorvath)
  • npm: Update devDeps.

6.0.0 (2021-07-05)

User-impacting

  • Breaking enhancement: Create as true ESM module
  • Breaking change: Utilize .cjs extension for UMD and CJS builds (very old browsers might not support, but needed with the change given that Webpack may complain if there even exists CJS within what it thinks is an ESM file, the ".js", our default)
  • Breaking change: Utilize .js extension instead of .mjs for now default ESM builds

Dev-impacting

  • npm: Add lint script
  • npm: Update devDeps.

5.1.0 (2021-06-24)

  • Enhancement: support double-quoted bracket notation
  • Linting: As per latest ash-nazg
  • npm: Update devDeps.

5.0.7 (2021-04-12)

  • Fix: Add packge.json to exports (@sebastiendavid)

5.0.6 (2021-04-09)

  • Fix: Remove static modifiers (@sdolski)
  • Linting: As per latest ash-nazg
  • npm: Update devDeps.

5.0.5 (2021-04-09)

  • Fix: Avoid cache corruption when the returned structure is modified. Fixes #102. (@tejodorus)

5.0.4 (2021-03-02)

  • Fix: allow falsey at values in filter (now may require checking for presence of @ in some cases); fixes #136
  • Docs: Add old missing release info (reconciling with GitHub releases)
  • Docs: Update README to reflect 1.2.0 was not a released version (subsume release details into 2.0.0)
  • Linting: As per latest ash-nazg
  • npm: Update devDeps.

5.0.3 (2021-02-06)

  • Fix: Add package exports for browser and umd (#145) (@gjvoosten)
  • Update: Build as per refactoring
  • Docs: Update as per typedoc update
  • Docs: Update license badges per latest
  • Linting: As per latest ash-nazg
  • CI: Update from Travis -> GitHub Actions
  • npm: Switch from eslint-plugin-sonarjs to eslint-plugin-radar
  • npm: Switch to pnpm
  • npm: Update devDeps.

5.0.2 (2021-01-15)

  • Fix: Proper Node CommonJS export; fixes #144

5.0.1 (2021-01-15)

  • Fix: Proper Node CommonJS export; fixes #143
  • Docs: Properly indicate new browser paths

5.0.0 (2021-01-14)

  • Breaking change: Add type: 'commonjs' and exports: {import, require} (with node-import-test npm script to demo)
  • Breaking change: Change paths for browser (now is dist/index-browser-umd.js or dist/index-browser-es.js) (for Node, main and module point to new Node-specific dist)
  • Breaking enhancement: Add browser for browser bundling; allowing static analysis environments, doesn't have however conditional code to require vm); for ESM browser bundling, now must check browser in Rollup Node resolver plugin; see README
  • Build: Update per latest devDeps.
  • Docs: Add Regex (.match) example on value (@jeffreypriebe)
  • Docs: Add Regex (.match) example on property
  • Docs: Fix XPath example (@humbertoc-silva)
  • Docs: Link to XPath 2.0 tester
  • Docs: Update badges per latest updates
  • Linting: quote props
  • Linting: As per latest ash-nazg
  • Testing: Fix browser tests
  • Testing: Add test case for setting values in callbacks (issue #126)
  • Testing: Add more at-sign tests
  • Testing: Bump timeout
  • Travis: Check Node 14
  • Travis: add default dist field to avoid extra config reporting
  • npm: Update from deprecated rollup-plugin-babel to @rollup/plugin-babel (and make babelHelpers explicit)
  • npm: Reorder scripts by test execution order
  • npm: Update devDeps

4.0.0 (2020-04-09)

  • Breaking change/fix: Disallow resultType from being lower-cased (broke parentProperty)
  • Breaking change: Expect Node >= 10
  • Build: As per latest rollup
  • Linting: Check hidden files; update as per latest ash-nazg
  • Docs: Update coverage badge
  • npm: Update devDeps

3.0.0 (2020-01-13)

  • Breaking change: Expect Node >= 8
  • Fix: Require json as "own" property
  • Fix: wrap: false returning inconsistent data types (@CacheControl)
  • Fix: Ensure throwing with a bad result type
  • Fix: Allow empty string keys
  • Fix: Avoid erring when value before parent selector is falsey
  • Fix: If resultType is "all", if path resolves internally to a non-array (string), ensure it is converted to an array before converting to pointer for pointer
  • Enhancement: Allow path as array in non-object signature
  • Docs: Add locally-generated badges for testing, coverage, etc.
  • Linting (ESLint): As per latest ash-nazg
  • Linting (ESLint): Remove redundant "use strict" with switch to ESM
  • Maintenance: 2 sp. for package.json
  • Testing: Add nyc for coverage
  • Testing: Test against source (using esm)
  • Testing: Improve coverage (more type operator tests)
  • Testing: Check vm
  • npm: Add test-cov script
  • npm: Update devDeps

2.0.0 (2019-11-23)

  • Breaking change: Throw TypeError instead of Error for missing otherTypeCallback when using @other
  • Breaking change: Throw TypeError instead of Error for missing path
  • Enhancement: Throw TypeError for missing json (fixes #110)
  • Enhancement: Use more efficient new Function over eval; also allows use of cyclic context objects
  • Enhancement: Add @root filter selector
  • Maintenance: Add .editorconfig
  • Docs: Document options in jsdoc; add return values to callbacks; fix constructor doc sig.
  • Testing: Add test for missing path or json
  • Testing: Remove unneeded closures
  • npm: Update devDeps and package-lock.json

1.1.0 (September 26, 2019)

  • Enhancement: Add explicit 'any' to evaluate() declaration (for use with noImplicitAny TypeScript option)
  • Build: Update minified build files
  • Travis: Update to check Node 6, 10, 12
  • npm: Ignore .idea/.remarkrc files
  • npm: Update devDeps (Babel, linting, Rollup, TypeScript related)
  • npm: Avoid eslint script within test script
  • npm: Ignore typescript docs

1.0.0 (August 7, 2019)

  • Add TypeScript declaration

0.20.2 (July 9, 2019)

  • supportsNodeVM check that works in GOJA, node and ReactNative. (@legander)

0.20.1 (June 12, 2019)

  • npm: Avoid adding core-js-bundle as peerDep. (fixes #95)

0.20.0 (June 4, 2019)

  • Build: Add browserslist for Babel builds
  • Linting: Conform to ESLint updates (jsdoc)
  • Testing: Switch from end-of-lifed nodeunit to Mocha
  • Testing: Add performance test to browser, but bump duration
  • npm: Update devDeps; add core-js-bundle to peerDependencies
  • npm: Ignore some unneeded files
  • Bump Node version in Travis to avoid erring with object rest in eslint-plugin-node routine

0.19.0 (May 16, 2019)

  • Docs (README): Indicate features, including performance (removing old note)
  • Docs (README): Add headings for setup and fix headings levels
  • Docs (README): Indicate parent selector was not present in original spec (not just not documented)
  • Docs (README): Fix escaping
  • Linting: Switch to Unix line breaks and other changes per ash-nazg, including linting Markdown JS
  • Linting: Use recommended .json extension
  • Linting: Switch to ash-nazg
  • Linting: Add lgtm.yml file for lgtm.com
  • npm: Update devDeps, and update per security audit

0.18.1 (May 14, 2019)

  • Fix: Expose pointer on resultType: "all"

0.18.0 (October 20, 2018)

  • Security enhancement: Use global eval instead of regular eval
  • Fix: Handle React-Native environment's lack of support for Node vm (@simon-scherzinger); closes #87
  • Refactoring: Use arrow functions, for-of, declare block scope vars closer to block
  • Docs: Clarify current wrap behavior
  • npm: Add Rollup to test scripts

0.17.0 (October 19, 2018)

  • Breaking change: With Node use, must now use require('jsonpath-plus').JSONPath.
  • Breaking change: Stop including polyfills for array and string includes (can get with @babel/polyfill or own)
  • Breaking change: Remove deprecated JSONPath.eval
  • License: Remove old and unneeded license portion from within source file (already have external file)
  • Fix: Support object shorthand functions on sandbox objects (toString() had not been working properly with them)
  • Enhancement: Add Rollup/Babel/Terser and module in package.json
  • Refactoring: Use ES6 features such as object shorthand
  • Linting: prefer const and no var
  • Testing: Replace custom server code with node-static and add opn-cli; mostly switch to ESM
  • npm: Update devDeps; add package-lock.json; remove non-functioning remark

0.16.0 (January 14, 2017)

  • Breaking change: Give preference to treating special chars in a property as special (override with backtick operator)
  • Breaking feature: Add custom ` operator to allow unambiguous literal sequences (if an initial backtick is needed, an additional one must now be added)
  • Fix: toPathArray caching bug
  • Improvements: Performance optimizations
  • Dev testing: Rename test file

0.15.0 (Mar 15, 2016)

  • Fix: Fixing support for sandbox in the case of functions
  • Feature: Use this if present for global export
  • Docs: Clarify function signature
  • Docs: Update testing section
  • Dev testing: Add in missing test for browser testing
  • Dev testing: Add remark linting to testing process (#70)
  • Dev testing: Lint JS test support files
  • Dev testing: Split out tests into eslint, remark, lint, nodeunit
  • Dev testing: Remove need for nodeunit build step
  • Dev testing: Simplify nodeunit usage and make available as npm run browser-test

0.14.0 (Jan 10, 2016)

  • Feature: Add @scalar() type operator (in JavaScript mode, will also include)

0.13.1 (Jan 5, 2016)

  • Fix: Avoid double-encoding path in results

0.13.0 (Dec 13, 2015)

  • Breaking change (from version 0.11): Silently strip ~ and ^ operators and type operators such as @string() in JSONPath.toPathString() calls.
  • Breaking change: Remove Array.isArray polyfill as no longer supporting IE <= 8
  • Feature: Allow omission of options first argument to JSONPath
  • Feature: Add JSONPath.toPointer() and "pointer" resultType option.
  • Fix: Correctly support callback and otherTypeCallback as numbered arguments to JSONPath.
  • Fix: Enhance Node checking to avoid issue reported with angular-mock
  • Fix: Allow for @ or other special characters in at-sign-prefixed property names (by use of [?(@['...'])] or [(@['...'])]).

0.12.0 (Dec 12, 2015 10:39pm)

  • Breaking change: Problems with upper-case letters in npm is causing us to rename the package, so have renamed package to "jsonpath-plus" (there are already package with lower-case "jsonpath" or "json-path"). The new name also reflects that there have been changes to the original spec.

0.11.2 (Dec 12, 2015 10:36pm)

  • Docs: Actually add the warning in the README that problems in npm with upper-case letters is causing us to rename to "jsonpath-plus" (next version will actually apply the change).

0.11.1 (Dec 12, 2015 10:11pm)

  • Docs: Give warning in README that problems in npm with upper-case letters is causing us to rename to "jsonpath-plus" (next version will actually apply the change).

0.11.0 (Dec 12, 2015)

  • Breaking change: For unwrapped results, return undefined instead of false upon failure to find path (to allow distinguishing of undefined--a non-allowed JSON value--from the valid JSON values, null or false) and return the exact value upon falsy single results (in order to allow return of null)
  • Deprecated: Use of jsonPath.eval(); use new class-based API instead
  • Feature: AMD export
  • Feature: By using self instead of window export, allow JSONPath to be trivially imported into web workers, without breaking compatibility in normal scenarios. See MDN on self
  • Feature: Offer new class-based API and object-based arguments (with option to run new queries via evaluate() method without resupplying config)
  • Feature: Allow new preventEval=true and autostart=false option
  • Feature: Allow new callback option to allow a callback function to execute as each final result node is obtained
  • Feature: Allow type operators: JavaScript types (@boolean(), @number(), @string()), other fundamental JavaScript types (@null(), @object(), @array()), the JSONSchema-added type, @integer(), and the following non-JSON types that can nevertheless be used with JSONPath when querying non-JSON JavaScript objects (@undefined(), @function(), @nonFinite()). Finally, @other() is made available in conjunction with a new callback option, otherTypeCallback, can be used to allow user-defined type detection (at least until JSON Schema awareness may be provided).
  • Feature: Support "parent" and "parentProperty" for resultType along with "all" (which also includes "path" and "value" together)
  • Feature: Support custom @parent, @parentProperty, @property (in addition to custom property @path) inside evaluations
  • Feature: Support a custom operator (~) to allow grabbing of property names
  • Feature: Support $ for retrieval of root, and document this as well as $.. behavior
  • Feature: Expose cache on JSONPath.cache for those who wish to preserve and reuse it
  • Feature: Expose class methods toPathString for converting a path as array into a (normalized) path as string and toPathArray for the reverse (though accepting unnormalized strings as well as normalized)
  • Fix: Allow ^ as property name
  • Fix: Support . within properties
  • Fix: @path in index/property evaluations

0.10.0 (Oct 23, 2013)

  • Feature: Support for parent selection via ^
  • Feature: Access current path via @path in test statements
  • Feature: Allowing for multi-statement evals
  • Improvements: Performance

0.9.0 (Mar 28, 2012)

  • Feature: Support a sandbox arg to eval
  • Improvements: Use vm.runInNewContext in place of eval