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.

Inconsistent Behavior of [] between version 1.7.0 and 1.8.3

See original GitHub issue

Consider the following input:

{
  "singleArray": [{"foo":"bar"}]
}

and JSONata expression: singleArray[]

In version 1.7.0, the evaluated result is

[
  {
    "foo": "bar"
  }
]

but in 1.8.3 it is

[
  [
    {
      "foo": "bar"
    }
  ]
]

Which evaluation is correct and why?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
dreuselcommented, Jan 28, 2021

Shouldn’t changes like this trigger a major version increment, as it breaks applications expecting the previous behavior?

1reaction
knollearycommented, Oct 21, 2020

Just found this issue as I was expecting $map to always return an array. The docs for $map says it returns an Array and doesn’t mention the singleton sequence case.

I found the workaround was to add [] after the $map function - this appears to ensure the result is always an array without causing the double nested array mentioned above:

$map($.payload, function($v) {  {"className":$v.className, "score":$v.score*100, "bbox":$v.bbox}})[]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Force nested arrays · Issue #399 · jsonata-js/jsonata - GitHub
on Jan 30, 2020. Maintain singleton sequence of array #405 ; on Jun 29, 2020. Inconsistent Behavior of [] between version 1.7.0 and...
Read more >
htmlinput - Rocket Software Documentation
Script the Component Behavior · Define the Structure and Layout of Forms and Reports · Create the Component Layout of Server Pages.
Read more >
dnf is inconsistent in how it treats weak dependencies across ...
Description of problem: On AArch64 and S390 we are unable to build software which uses ruby - all tests fail due to lack...
Read more >
What's New - Chaos Vantage
Synchronized value defaults and ranges between Vantage UI and "Render animation via Live Link" dialog in 3Ds Max .
Read more >
Digital Asset Manager Add-on Documentation - All release notes
Behavior has been updated to improve consistency in the way error messages ... [29229] Inconsistent display of Upload and Edit buttons between a...
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