Skip to content

Releases

Version 2.3.0

Choose a tag to compare

@jg-rp jg-rp released this 22 Nov 07:10

Fixes

  • Fixed deep equality in the JSON Patch test operation. Previously we would treat True as 1 and False as 0 when comparing nested data structures.
  • Fixed handling of UTF-16 escape sequences in JSON Pointer tokens when the unicode_escape argument is True. Previously we were unintentionally mangling Unicode characters with codecs.decode and unicode-escape. Now we replace \uXXXX and \uXXXX\uXXXX sequences without touching Unicode characters. See #140.
  • Fixed JSONPath expression comparison between bool and int using the < or > operators. Previously we would treat True as 1 and False as 0.
  • Fixed JSONPath property name parsing to accept the full range of allowed Unicode code points and reject names containing a hyphen (-) in strict mode.
  • Fixed parsing of JSONPath string literals containing escape sequences less than or equal to \u001F. Previously we would incorrectly reject such escape sequences, now they are allowed.

Changes

  • Removed the iregexp-check dependency. We now include faster and more correct implementations of check_iregexp and map_iregexp in this project.
  • Added the check_iregexp argument to jsonpath.function_extensions.Match and jsonpath.function_extensions.Search for controlling I-Regexp validation. By default, check_iregexp is True if the regex package is installed.

Version 2.2.2

Choose a tag to compare

@jg-rp jg-rp released this 17 Oct 08:42

Fixes

  • JSON Patch move and copy operations now use add semantics for their target locations. Previously it was not possible to move or copy to the end of an array with the special - index, and we would silently append to arrays given an index greater than the array's length. We now raise a JSONPatchError if the target index is greater than the number of elements in the array.
  • Fixed JSONPatch move operations with immutable Mapping or Sequence source objects. Previously we silently ignored the internal remove op if the source was immutable, making the operation a copy. Now we raise a JSONPatchError.

Versoin 2.2.1

Choose a tag to compare

@jg-rp jg-rp released this 07 Jul 09:57

Fixes

  • JSONPath parser recursion limit failures now raise JSONPathRecursionError, preserving the original RecursionError as the cause. JSONPathRecursionError now also subclasses RecursionError, allowing existing except RecursionError handlers to continue working.

Version 2.2.0

Choose a tag to compare

@jg-rp jg-rp released this 05 Jul 08:26

Fixes

  • Fixed lexing of quoted name selectors ending in an escaped backslash, like $['a\\']['b']. The lexer's look-behind for the closing quote treated a quote following an escaped backslash (\\) as an escaped quote (\'), so these selectors failed to tokenize. This also broke the RFC 9535 normalized path round-trip: normalized paths produced for object keys containing backslashes could not be parsed back. See #132.
  • Fixed atomic JSONPatch application when a patch op replaces the document root.

Features

  • Added patch.patched(ops, data) and JSONPatch.patched(data). patched() is a non-mutating form of JSONPatch application. It always performs a deep copy of data and returns the patched copy. See #131.

Version 2.1.0

Choose a tag to compare

@jg-rp jg-rp released this 26 Jun 06:27

Added patch.atomic(patch, data) and JSONPatch.atomic(data). atomic() is similar to apply(), but preserves input data if a patch operation fails. See #129.

Version 2.0.2

Choose a tag to compare

@jg-rp jg-rp released this 10 Jan 07:54

Fixes

  • Fixed parsing of non-standard JSONPath regular expression literals containing an escaped solidus (/). This affected queries using the regex operator =~, like $.some[?(@.thing =~ /fo\/[a-z]/)], not standard match and search functions. See #124.

Version 2.0.1

Choose a tag to compare

@jg-rp jg-rp released this 13 Sep 08:02

Fixes

  • Fixed JSON pointers with negative indices.

    Previously, negative indices were resolved against array-like values, but the JSON Pointer specification (RFC 6901) does not permit negative array indexes. We now raise a JSONPointerIndexError when a JSON Pointer attempts to resolve an array element using a negative index.

    For users who require negative indices in JSON Pointers, you can set JSONPointer.min_int_index to a suitably negative integer, like JSONPointer.min_int_index = -(2**53) + 1.

    See #116.

  • Fixed the JSON Patch add operation.

    Previously, a JSONPatchError was raised when pointing to an array index equal to the array's length. Now we append to arrays in such cases. See #117.

Version 2.0.0

Choose a tag to compare

@jg-rp jg-rp released this 09 Sep 13:11

JSONPath syntax changes

These breaking changes affect the default configuration of Python JSONPath. Version 2 also introduces a new strict mode, which enforces full compliance with RFC 9535. See optional dependencies and the syntax guide for details.

  • Bracket notation - unquoted property names are no longer treated as quoted names.
    • Before: $[foo], $['foo'], and $["foo"] were equivalent.
    • Now: $[foo] is a singular query selector. With an implicit root identifier, $.a[b] is equivalent to $.a[$.b]. See Singular query selector.
  • Filter expressions - float literals must follow the RFC.
    • .1 is now invalid (use 0.1)
    • 1. is now invalid (use 1.0)
  • Slice selectors - indexes and steps must follow the RFC.
    • Leading zeros and negative zero are no longer valid and raise JSONPathSyntaxError.
  • Dot notation - no whitespace is allowed between . or .. and the following name. Whitespace before the dot is still permitted.

JSONPath function extension changes

  • Added the startswith(value, prefix) function extension. Returns True if both arguments are strings and prefix is a prefix of value. See the filter functions documentation.
  • Reimplemented the non-standard keys() function extension. It used to be a simple Python function, jsonpath.function_extensions.keys. Now it is a "well-typed" class, jsonpath.function_extensions.Keys. See the filter functions documentation.
  • Added cache_capacity, debug and thread_safe arguments to jsonpath.function_extensions.Match and jsonpath.function_extensions.Search constructors.

JSONPath features

  • Added the Keys filter selector.
  • Added the Singular query selector.
  • Match and search function extensions now use the regex package (if installed) instead of re. See optional dependencies.
  • Added the strict argument to all convenience functions, the CLI and the JSONPathEnvironment constructor. When strict=True, all non-standard extensions and relaxed parsing rules are disabled.
  • Added class variable JSONPathEnvironment.max_recursion_depth to control the maximum recursion depth of descendant segments.
  • Improved exception messages (prettier, more informative).

Python API changes

  • Renamed class variable JSONPathEnvironment.fake_root_token to JSONPathEnvironment.pseudo_root_token.

Low level API changes

These only affect projects customizing the JSONPath lexer or parser.

  • The tokens produced by the JSONPath lexer have changed. Previously we broadly skipped some punctuation and whitespace. Now the parser can make better choices about when to accept whitespace and do a better job of enforcing dots.
  • We've change the internal representation of compiled JSONPath queries. We now model segments and selectors explicitly and use terminology that matches RFC 9535.

Version 1.3.2

Choose a tag to compare

@jg-rp jg-rp released this 15 Aug 07:36

Fixes

  • Fixed JSONPath filter context data in embedded JSONPath queries. We were failing to pass on said context data when resolving embedded queries. See #103.

Version 1.3.1

Choose a tag to compare

@jg-rp jg-rp released this 22 Jun 08:09

Fixes

  • Fixed the non-standard JSON Patch operation, addap. Previously it was behaving like addne. See #81.
  • Fixed JSON Patch ops that operate on mappings and have a target that looks like an int. We now ensure the target is a string. See #82.