Jsonpath transformation doesn't work with null values in json data. #4870
Comments
I which cases does an error in the
logs:
|
Thank you for trying this out with an example. I am wondering this is always the case? I could not find any documentation for this behavior, did you come across any? |
Just the JsonPath readme. It can be configured to return null if an exception occurs, but that isn't the case in this implementation, so i don't think itshould return null unless the requested field is null. @kaikreuzer or @SJKA, any more input on this? |
Sounds like what we need. Do you want to come up with a PR for this? |
As you can see from the discussion in #4379, we were all a little unsure what to return in that case. With your analysis it indeed would make sense to define null as a valid outcome. If the element doesn't exist it will still throw the TransformationException. It can't be the real |
...in case the element really exists and is set to NULL. fixes eclipse-archived#4870 Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
That would solve my problem, just need to change null to "NULL" in my rule. Thanks @SJKA! |
...in case the element really exists and is set to NULL. fixes #4870 Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
…-archived#4909) ...in case the element really exists and is set to NULL. fixes eclipse-archived#4870 Signed-off-by: Simon Kaufmann <simon.kfm@googlemail.com>
Since commit f1c63ba7177bf007b457f60676c8701e87c74343 the jsonpath transformation no longer work properly when the json data contains null values. Instead of returning null it returns the whole json string when accessing a key with null value.
For example when trying to access the 'upgrade' field in
{"current":{"name":"8461R2","version":8461,"release":2},"upgrade":null}
the whole string is returned instead of null.
Steps to reproduce:
returns
More info in this post on the OpenHAB forum.
The text was updated successfully, but these errors were encountered: