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

[wip] take better advantage of jsonptr #45

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

asmello
Copy link
Contributor

@asmello asmello commented Oct 18, 2024

jsonptr has been upgraded with more specialised utility functions that this crate reimplements. Let's delegate low-level string manipulation to the source crate and take advantage of the nifty new zero-copy APIs.

Still work in progress. Blocking on chanced/jsonptr#80 due to a regression in catching an edge case with + prefixes in array indices.

@@ -72,12 +72,11 @@ fn run_patch_test_case(tc: &PatchTestCase, kind: PatchKind) -> Result<Value, Str
// Patch and verify that in case of error document wasn't changed
let patch: Patch = serde_json::from_value(tc.patch.clone()).map_err(|err| err.to_string())?;
json_patch::patch(&mut actual, &patch)
.map_err(|e| {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an incidental clippy suggestion.

Value::Array(ref mut arr) if allow_last && last_unescaped == "-" => Ok(arr.pop().unwrap()),
Value::Array(ref mut arr) => {
let idx = parse_index(last_unescaped, arr.len())?;
// XXX: is this really correct? semantically it seems off, `-` refers to an empty position, not the last element
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@idubrov could you share some context here?

@@ -15,7 +15,8 @@ default = ["diff"]
diff = []

[dependencies]
jsonptr = "0.6.0"
# jsonptr = "0.6.0"
jsonptr = { git = "https://github.com/asmello/jsonptr", branch = "main" }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Temporary until the upstream PRs get merged

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.

1 participant