Jsonata chain operator giving different results

Given some JSON:

{
  "A": 1,
  "B" : 2,
  "C": 3
}

I'd expect this Jasonata statement $spread($)[*=2] to gives these results (which it does indeed):

 {
   "B": 2
 }

But when I use what I believe to be semantically the same statement but use the chain operator: $~>$spread()[*=2] it gives the results:

[
  {
    "A": 1
  },
  {
    "B": 2
  },
  {
    "C": 3
  }
]

Could anyone explain why Jsonata processes those two statements which in my estimation should yield identical results, but are handled so differently? Is there something I don't understand about the chain operator?

Thanks in advance!

The chain parts need to be in parentheses
e.g

($~>$spread())[*=2]

[edit] removed typo

1 Like

Thank you! Great insight! Do you understand why? Is it an order of operations problem?

I believe the spread is applying the filter to each property of the object, rather than the finished array.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.