Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

handle indefinite results in JsonPath transformations #4951

Merged
merged 2 commits into from Jan 23, 2018

Conversation

sjsf
Copy link
Contributor

@sjsf sjsf commented Jan 19, 2018

...as JsonPath may return a List if multiple elements matched,
even if they were correctly filtered down to a single element.

fixes #4862
Signed-off-by: Simon Kaufmann simon.kfm@googlemail.com

...as JsonPath may return a List if multiple elements matched,
even if they were correctly filtered down to a single element.

fixes eclipse-archived#4862
Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
@ThomDietrich
Copy link
Contributor

Hey Simon,
during #4862 I realized that part of the issue is the jsonpath implementation used and the fact that it behaves slightly different then broadly documented. Could you please add a short paragraph to the README?

return list.get(0).toString();
}
if (list.size() > 1) {
logger.warn("The JsonPath expression yielded more than one result: {}", list);
Copy link
Contributor

Choose a reason for hiding this comment

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

Imho this error doesn't imply that NULL is returned... What's the end user supposed to do here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the end user supposed to do here?

Check out the code from github and try to understand the program's behavior? 😉

How about:

Returning NULL because the JsonPath expression yielded more than one result: {} - did you forget to add a filter expression?

Copy link
Contributor

Choose a reason for hiding this comment

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

A statement by a true developer 😁 How about

JsonPath expression with more than one result not allowed, please adapt your selector. Result: {}

(Result in the end because it could become nasty...)

Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
@maggu2810
Copy link
Contributor

@ThomDietrich Would you like to approve that changes?

Copy link
Contributor

@ThomDietrich ThomDietrich left a comment

Choose a reason for hiding this comment

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

Lgtm! Thanks @SJKA

@maggu2810 maggu2810 merged commit 678303e into eclipse-archived:master Jan 23, 2018
dgajic pushed a commit to dgajic/smarthome that referenced this pull request Jan 27, 2018
…ed#4951)

...as JsonPath may return a List if multiple elements matched,
even if they were correctly filtered down to a single element.

fixes eclipse-archived#4862
Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
@htreu htreu added this to the 0.10.0 milestone Oct 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSONPath transformation fails on indefinite paths
4 participants