$boolean(arg) when arg is no-match
See original GitHub issueJust a query. I wanted something that returns “true” if a arg path evaluates to truthy, and “false” if falsey or not found (no match).
data:
{
"_formValues": {
"test": true
}
}
Jsonata expressiosn:
$not(_formValues.test)
returns false
$not(_formValues.test2)
returns true
But:
$boolean(_formValues.test)
returns true
$boolean(_formValues.test2)
returns *no match*
I found it a bit inconsistent that a $boolean(arg)
can return *no match*
. Should it be returning false
instead when hit against a no match? Or perhaps someone can explain why this is perfectly good and logical 😃
Using: Jsonata 1.8.2 (as in the exerciser)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Parsing boolean values with argparse - python - Stack Overflow
I would like to use argparse to parse boolean command-line arguments written as "--foo True" or "--foo False". For example:
Read more >Boolean | The Rascal Meta Programming Language
Most operators are self-explanatory except the match (:=) and no match (! ... The left argument of the && operator is evaluated: the...
Read more >BooleanUtils (Apache Commons Lang 3.12.0 API)
Converts a String to a Boolean throwing an exception if no match. NOTE: This method may return null and may throw a NullPointerException...
Read more >Value Matching - R
Any value in x matching a value in this vector is assigned the nomatch value. ... pmatch and charmatch for (partial) string matching,...
Read more >Matcher (Java Platform SE 7 ) - Oracle Help Center
Invoking this method with an argument of true will set this matcher to use transparent bounds. If the boolean argument is false, then...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry this is breaking your expression, but I consider the previous inconsistent behaviour of the
$not
function with undefined inputs to be a bug, and so was fixed in a patch release.In general I try to keep the language as stable as possible, but there have been a few cases (like this) where I have fixed up behavioural ‘edge cases’ for improved consistency. In your example, you were relying on this behaviour and subsequently have to change your code. Apologies for that!
Thanks. I’d probably remove the
$not
from your expression and use this: