Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added negate operator '!' #54

Merged
merged 4 commits into from
Nov 23, 2023
Merged

Added negate operator '!' #54

merged 4 commits into from
Nov 23, 2023

Conversation

catalinstochita
Copy link
Contributor

No description provided.

@catalinstochita
Copy link
Contributor Author

Hi. I'm using this library at work along with a java library too. We have some filters that are using the '!' to negate the expression and is not supported in rust.
I have made the changes and it seems to works. I would appreciate it if you could review my implementation. Thanks

@besok
Copy link
Owner

besok commented Nov 21, 2023

Great to hear the library is useful.
Thank you for the PR.

@besok besok marked this pull request as ready for review November 21, 2023 07:09
@besok
Copy link
Owner

besok commented Nov 21, 2023

closes #55

@catalinstochita
Copy link
Contributor Author

Looks like this needs more work.

let json: Box<Value> = Box::new(json!({"first":{"second":{"active":1}}}));
let path: Box<JsonPathInst> = Box::from(
    JsonPathInst::from_str("$.first[?(!(@.second.active == 1) || @.second.active == 1)]")
        .expect("the path is correct"),
);
let finder = JsonPathFinder::new(json, path);
let v = finder.find_slice();
assert_eq!(v, vec![Slice(&json!({"second":{"active": 1}}), "$.['first']".to_string())]);
assertion `left == right` failed
left: [NoValue]
right: [Slice(Object {"second": Object {"active": Number(1)}}, "$.['first']")]

The negate evaluates only the first expression, we need to be able to chain them

Copy link
Owner

@besok besok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.
Thanks for catching it right up.

@besok
Copy link
Owner

besok commented Nov 22, 2023

Thanks for the changes but
There is a fail in rust fmt.
Just kick off the following command:

cargo fmt --all -- --check

locally and reformat the files or the whole project using rustfmt if it is possible.

@besok besok merged commit 89a0630 into besok:main Nov 23, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants