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

Issue with Version 2.8 - JsonPath.java#set() and JsonPath.java#add() #977

Open
suhailSj opened this issue Jan 4, 2024 · 2 comments
Open

Comments

@suhailSj
Copy link

suhailSj commented Jan 4, 2024

set/add method evaluates the path and if not present throws the error, ideally this should not be the case.
ideally set sets the field on the desired path. In case of nested fields we should be verifying till the parent node only.

This change is breaking the code where we are setting the field in json using set method.

EvaluationContext evaluationContext = path.evaluate(jsonObject, jsonObject, configuration, true);
        if (evaluationContext.getPathList().isEmpty()) {
            boolean optSuppressExceptions = configuration.containsOption(Option.SUPPRESS_EXCEPTIONS);
            if (optSuppressExceptions) {
                return handleMissingPathInContext(configuration);
            } else {
                throw new PathNotFoundException();
            }
        }

either we should remove if or we should only check till parent element. as this check is defying the functionality of set method. Suggestions please.

@suhailSj suhailSj changed the title Issue with Version 2.8 - JsonPath.java#set() Issue with Version 2.8 - JsonPath.java#set() and JsonPath.java#add() Jan 9, 2024
@suhailSj
Copy link
Author

suhailSj commented Jan 9, 2024

If admin confirms to this change i will raise a new CR and remove this check from #add method.

@akanshSirohi
Copy link

@suhailSj I am stucked on this kind of issue already, please check and let me know if you faced this issue or know the solution.
#982 (comment)

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

2 participants