Skip to content

Commit

Permalink
add v + doc dsc
Browse files Browse the repository at this point in the history
  • Loading branch information
besok committed Oct 15, 2024
2 parents f8ee8db + 5467b2d commit 10f21aa
Show file tree
Hide file tree
Showing 14 changed files with 1,169 additions and 717 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@
- Performance improvements
- Change the contract for the struct of errors
- **`0.7.0`**
- Bug fixes and api changes
- Bug fixes and api changes
- **`0.7.1`**
- add Display to JsonPath
- **`0.7.2`**
- add JsonLike trait
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "jsonpath-rust"
description = "The library provides the basic functionality to find the set of the data according to the filtering query."
version = "0.7.0"
version = "0.7.2"
authors = ["BorisZhguchev <[email protected]>"]
edition = "2021"
license = "MIT"
Expand Down
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,26 @@ This is enum type which represents:

- `Slice` - a point to the passed original json
- `NewValue` - a new json data that has been generated during the path( for instance length operator)
- `NoValue` - indicates there is no match between given json and jsonpath in the most cases due to absent fields or inconsistent data.
- `NoValue` - indicates there is no match between given json and jsonpath in the most cases due to absent fields or
inconsistent data.

To extract data there are two methods, provided on the `value`:

```rust
let v:JsonPathValue<Value> =...
v.to_data();
v.slice_or(&some_dafault_value)
v.slice_or( & some_dafault_value)
```

### Find

there are 4 different functions to find data inside a `value`.
All take references, to increase reusability. Especially json parsing and jsonpath parsing can take significant time, compared to a simple find.
All take references, to increase reusability. Especially json parsing and jsonpath parsing can take significant time,
compared to a simple find.

The methods `find`, `find_as_path`, `find_slice` and `find_slice_ptr` take the same inputs, but handle them differently depending on your usecase. They are further described in the [docs](https://docs.rs/jsonpath-rust/latest/jsonpath_rust/enum.JsonPath.html#implementations).
The methods `find`, `find_as_path`, `find_slice` and `find_slice_ptr` take the same inputs, but handle them differently
depending on your usecase. They are further described in
the [docs](https://docs.rs/jsonpath-rust/latest/jsonpath_rust/enum.JsonPath.html#implementations).

```rust
use jsonpath_rust::{JsonPath, JsonPathValue};
Expand Down Expand Up @@ -289,12 +293,18 @@ https://docs.rs/jsonpath-rust/latest/jsonpath_rust/parser/model/enum.JsonPath.ht
The internal structure of the `JsonPathIndex` can be found here:
https://docs.rs/jsonpath-rust/latest/jsonpath_rust/parser/model/enum.JsonPathIndex.html

### JsonLike

The library provides a trait `JsonLike` that can be implemented for any type.
This allows you to use the `JsonPath` methods on your own types.

## How to contribute

TBD

## How to update version
- update files
- commit them
- add tag `git tag -a v<Version> -m "message"`
- git push origin <tag_name>

- update files
- commit them
- add tag `git tag -a v<Version> -m "message"`
- git push origin <tag_name>
4 changes: 2 additions & 2 deletions benches/regex.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use criterion::{criterion_group, criterion_main, Criterion};
use jsonpath_rust::{JsonPath, JsonPathQuery};
use serde_json::json;
use serde_json::{json, Value};
use std::str::FromStr;

struct SearchData {
Expand All @@ -23,7 +23,7 @@ fn regex_perf_test_without_reuse() {
}

fn json_path_compiling() {
let _v = JsonPath::from_str(PATH).unwrap();
let _v = JsonPath::<Value>::from_str(PATH).unwrap();
}

pub fn criterion_benchmark(c: &mut Criterion) {
Expand Down
Loading

0 comments on commit 10f21aa

Please sign in to comment.