Skip to content

Releases: hiltontj/serde_json_path

v0.6.7

03 Mar 22:44
a9f8f08
Compare
Choose a tag to compare

0.6.7 (3 March 2024)

  • testing:support tests for non-determinism in compliance test suite (#85)
  • fixed:bug preventing registered functions from being used as arguments to other functions (#84)

v0.6.6

24 Feb 03:55
f2004fc
Compare
Choose a tag to compare

0.6.6 (23 February 2024)

  • docs:update links to refer to RFC 9535 (#81)

v0.6.5

03 Feb 16:34
bd507d4
Compare
Choose a tag to compare

0.6.5 (3 February 2024)

Added:NormalizedPathandPathElementtypes (#78)

TheNormalizedPathstruct represents the location of a node within a JSON object. Its representation is like so:

pubstructNormalizedPath<'a>(Vec<PathElement<'a>);

pubenumPathElement<'a>{
Name(&'astr),
Index(usize),
}

Several methods were included to interact with aNormalizedPath,e.g.,first,last,get,iter,etc., but notably there is ato_json_pointermethod, which allows direct conversion to a JSON Pointer to be used with theserde_json::Value::pointerorserde_json::Value::pointer_mutmethods.

The newPathElementtype also comes equipped with several methods, and both it andNormalizedPathhave eagerly implemented traits from the standard library /serdeto help improve interoperability.

Added:LocatedNodeListandLocatedNodetypes (#78)

TheLocatedNodeListstruct was built to have a similar API surface to theNodeListstruct, but includes additional methods that give access to the location of each node produced by the original query. For example, it has thelocationsandnodesmethods to provide dedicated iterators over locations or nodes, respectively, but also provides theitermethod to iterate over the location/node pairs. Here is an example:

useserde_json::{json,Value};
useserde_json_path::JsonPath;
letvalue =json!({"foo":{"bar":1,"baz":2}});
letpath =JsonPath::parse("$.foo.*")?;
letquery = path.query_located(&value);
letnodes:Vec<&Value>= query.nodes().collect();
assert_eq!(nodes, vec![1,2]);
letlocs:Vec<String>= query
.locations()
.map(|loc| loc.to_string())
.collect();
assert_eq!(locs,["$['foo']['bar']","$['foo']['baz']"]);

The location/node pairs are represented by theLocatedNodetype.

TheLocatedNodeListprovides one unique bit of functionality overNodeList:deduplication of the query results, via theLocatedNodeList::dedupandLocatedNodeList::dedup_in_placemethods.

Other Changes

  • internal:address new clippy lints in Rust 1.75 (#75)
  • internal:address new clippy lints in Rust 1.74 (#70)
  • internal:code clean-up (#72)

v0.6.4

09 Nov 19:58
f144e6e
Compare
Choose a tag to compare

0.6.4 (9 November 2023)

  • added:is_empty,is_more_than_one,andas_more_than_onemethods toExactlyOneError(#65)
  • fixed:allow whitespace before dot-name selectors (#67)
  • fixed:ensure that the check== -0in filters works as expected (#67)

v0.6.3

17 Sep 18:46
51eec54
Compare
Choose a tag to compare

0.6.3 (17 September 2023)

  • documentation:Add line describing Descendant Operator (#53)
  • documentation:Improve example in Filter Selector section of main docs (#54)
  • documentation:Improve examples in Slice Slector section of main docs (#55)
  • documentation:Other improvements to documentation (#56)
  • fixed:Formulate the regex used by thematchfunction to correctly handle regular expressions with leading or trailing|characters (#61)

v0.6.2

13 Jul 11:16
c7f2315
Compare
Choose a tag to compare

0.6.2 (13 July 2023)

  • fixed:Fixed an issue in the evaluation ofSingularQuerys that was producing false positive query results when relative singular queries, e.g.,@.bar,were being used as comparables in a filter, e.g.,$.foo[?(@.bar == 'baz')](#50)

v0.6.1

06 Jul 12:17
50fbe43
Compare
Choose a tag to compare

0.6.1 (5 July 2023)

  • documentation:Updated links to JSONPath specification to latest version (base 14)#43
  • fixed:Support newline characters in query strings where previously they were not being supported#44

v0.6.0

03 Apr 02:13
036881c
Compare
Choose a tag to compare

0.6.0 (2 April 2023)

Function Extensions (#32)

This release introduces the implementation ofFunction Extensionsinserde_json_path.

This release ships with support for the standard built-in functions that are part of the base JSONPath specification:

  • length
  • count
  • match
  • search
  • value

These can now be used in your JSONPath query filter selectors, and are defined in the crate documentation
in thefunctionsmodule.

In addition, the#[function]attribute macro was introduced to enable users ofserde_json_pathto define
their own custom functions for use in their JSONPath queries.

Thefunctionsmodule (added)

In addition to the documentation/definitions for built-in functions, thefunctionsmodule includes three new types:

  • ValueType
  • NodesType
  • LogicalType

These reflect the type system defined in the JSONPath spec. Each is available through the public API, to be used in custom
function definitions, along with the#[function]attribute macro.

The#[function]attribute macro (added)

A new attribute macro:#[function]was introduced to allow users ofserde_json_pathto define their
own custom functions for use in their JSONPath queries.

Along with the new types introduced by thefunctionsmodule, it can be used like so:

useserde_json_path::functions::{NodesType,ValueType};

/// A function that takes a node list, and optionally produces the first element as
/// a value, if there are any elements in the list.
#[serde_json_path::function]
fnfirst(nodes:NodesType)->ValueType{
matchnodes.first(){
Some(v)=>ValueType::Node(v),
None=>ValueType::Nothing,
}
}

Which will then allow you to use afirstfunction in your JSONPath queries:

$[? first(@.*) > 5 ]

Usage offirstin you JSONPath queries, like any of the built-in functions, will be validated at parse-time.

The#[function]macro is gated behind thefunctionsfeature, which is enabled by default.

Functions defined using the#[function]macro will override any of the built-in functions that are part
of the standard, e.g.,length,count,etc.

Changed theErrortype (breaking)

TheErrortype was renamed toParseErrorand was updated to have more concise error messages. It was
refactored internally to better support future improvements to the parser. It is now a struct, vs. an enum,
with a private implementation, and two core APIs:

  • message():the parser error message
  • position():indicate where the parser error was encountered in the JSONPath query string

This gives far more concise errors than the pre-existing usage ofnom's built-inVerboseErrortype.
However, for now, this leads to somewhat of a trade-off, in that errors that are not specially handled
by the parser will present as just"parser error"with a position. Over time, the objective is to
isolate cases where specific errors can be propagated up, and give better error messages.

Repository switched to a workspace

With this release,serde_json_pathis split into four separate crates:

  • serde_json_path
  • serde_json_path_macros
  • serde_json_path_macros_internal
  • serde_json_path_core

serde_json_pathis still the entry point for general consumption. It still contains some of the key
components of the API, e.g.,JsonPath,JsonPathExt,andError,as well as the entireparsermodule.
However, many of the core types used to represent the JSONPath model, as defined in the specification,
were moved intoserde_json_path_core.

This split was done to accommodate the new#[function]attribute macro, which is defined within the
serde_json_path_macros/macros_internalcrates, and discussed below.

Other Changes

  • added:updated to latest version of CTS to ensure compliance#33
  • added:implementEqforJsonPath#34
  • breaking::Changed the name ofErrortype toParseError#36