hiltontj / serde_json_path

Query serde_json Values with JSONPath
https://serdejsonpath.live/
MIT License
50 stars 3 forks source link

[WIP][1] Function Extensions #8

Closed hiltontj closed 1 year ago

hiltontj commented 1 year ago

This PR implements the Function Extension point in the JSONPath spec. This is still a WIP.

Not only are function extensions enabled by this PR, but a means is provided for crate users to define and register their own functions.

This largely hinges on the type system defined in the JSONPath spec, which is still being finalized by the working group. That, compounded with the fact that I have taken some liberties to get a working solution is why I will keep this in WIP for the time being.

Updates

Extensible function definitions via the inventory crate

Functions used by serde_json_path are compiled into an inventory using the inventory crate. This allows users of the crate to also define their own functions. See the tests/functions.rs integration test file for an example of such.

The crate ships with a set of built-in functions that can be gated with the feature flag registry, in case the user wants to define their own, e.g., length and match functions.

TODO

Introduce tracing

tracing was added to help debug parser, and query execution. This is gated with a feature, trace.

hiltontj commented 1 year ago

Closing this as the branch has come a massively long way, and I will open a new PR to summarize the changes.