Repository navigation
Releases
Version 2.3.0
Fixes
- Fixed deep equality in the JSON Patch
testoperation. Previously we would treatTrueas1andFalseas0when comparing nested data structures. - Fixed handling of UTF-16 escape sequences in JSON Pointer tokens when the
unicode_escapeargument isTrue. Previously we were unintentionally mangling Unicode characters withcodecs.decodeandunicode-escape. Now we replace\uXXXXand\uXXXX\uXXXXsequences without touching Unicode characters. See #140. - Fixed JSONPath expression comparison between
boolandintusing the<or>operators. Previously we would treatTrueas1andFalseas0. - 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-checkdependency. We now include faster and more correct implementations ofcheck_iregexpandmap_iregexpin this project. - Added the
check_iregexpargument tojsonpath.function_extensions.Matchandjsonpath.function_extensions.Searchfor controlling I-Regexp validation. By default,check_iregexpisTrueif theregexpackage is installed.
Version 2.2.2
Fixes
- JSON Patch
moveandcopyoperations now useaddsemantics 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 aJSONPatchErrorif the target index is greater than the number of elements in the array. - Fixed JSONPatch
moveoperations with immutable Mapping or Sequence source objects. Previously we silently ignored the internalremoveop if the source was immutable, making the operation a copy. Now we raise aJSONPatchError.
Versoin 2.2.1
Fixes
- JSONPath parser recursion limit failures now raise
JSONPathRecursionError, preserving the originalRecursionErroras the cause.JSONPathRecursionErrornow also subclassesRecursionError, allowing existing exceptRecursionErrorhandlers to continue working.
Version 2.2.0
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)andJSONPatch.patched(data).patched()is a non-mutating form of JSONPatch application. It always performs a deep copy ofdataand returns the patched copy. See #131.
Version 2.1.0
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
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 standardmatchandsearchfunctions. See #124.
Version 2.0.1
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
JSONPointerIndexErrorwhen 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_indexto a suitably negative integer, likeJSONPointer.min_int_index = -(2**53) + 1.See #116.
-
Fixed the JSON Patch
addoperation.Previously, a
JSONPatchErrorwas 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
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.
- Before:
- Filter expressions - float literals must follow the RFC.
.1is now invalid (use0.1)1.is now invalid (use1.0)
- Slice selectors - indexes and steps must follow the RFC.
- Leading zeros and negative zero are no longer valid and raise
JSONPathSyntaxError.
- Leading zeros and negative zero are no longer valid and raise
- 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. ReturnsTrueif both arguments are strings andprefixis a prefix ofvalue. 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,debugandthread_safearguments tojsonpath.function_extensions.Matchandjsonpath.function_extensions.Searchconstructors.
JSONPath features
- Added the Keys filter selector.
- Added the Singular query selector.
- Match and search function extensions now use the
regexpackage (if installed) instead ofre. See optional dependencies. - Added the
strictargument to all convenience functions, the CLI and theJSONPathEnvironmentconstructor. Whenstrict=True, all non-standard extensions and relaxed parsing rules are disabled. - Added class variable
JSONPathEnvironment.max_recursion_depthto control the maximum recursion depth of descendant segments. - Improved exception messages (prettier, more informative).
Python API changes
- Renamed class variable
JSONPathEnvironment.fake_root_tokentoJSONPathEnvironment.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
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.