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

Support for test operation with null value against empty path #37

Closed
piotr-bugara-gravity9 opened this issue Jun 29, 2023 · 1 comment
Closed
Assignees

Comments

@piotr-bugara-gravity9
Copy link

Issue copied from:
java-json-tools#133

When performing a test operation, we should be able to test that a path inside a document is null. Instead, the library always throws an empty path exception without even checking if the value to test against is null.

Example:

Given the document:

{
"field1": {"id": 123},
"field2": {"id": 321}
}

and the patch:

[
{"op": "test", "path": "field3", "value": null},
{"op": "add", "path": "field3", "value": {"id": 456}}
]

Expected: Successful patch
Actual: Throws empty path exception

If operations like this were supported in the library it would allow users to perform "put if absent" operations inside json documents, since all the patch operations are executed atomically, which could be useful for several applications.

@piotr-bugara-gravity9 piotr-bugara-gravity9 self-assigned this Jun 29, 2023
piotr-bugara-gravity9 pushed a commit that referenced this issue Jun 29, 2023
Changed access modifier of JsonPathParser class and it's method to package scope.
piotr-bugara-gravity9 pushed a commit that referenced this issue Jun 30, 2023
… or it is equal to null. Added examples in README.md
@piotr-bugara-gravity9
Copy link
Author

Test operation is not needed as we support JsonPath.
We can do an add operation with filter predicate to add value to object that does not have path or it's value is equal to null.

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

No branches or pull requests

1 participant