json-path/JsonPath

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

suhailSj opened this issue · 2 comments

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.

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

@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)