question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

$boolean(arg) when arg is no-match

See original GitHub issue

Just 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:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
andrew-colemancommented, Apr 28, 2020

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!

0reactions
andrew-colemancommented, Apr 29, 2020

Thanks. I’d probably remove the $not from your expression and use this:

$sift(  λ($v,$k) { $k ~> /^lineItem|^packages/ ? false: true }  )
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found