Skip to content

$map does not return an array for input arrays of length 1 #708

@vecerek

Description

@vecerek

According to the docs, $map should return an array. However, if the input data is an array containing exactly one element, it returns the value returned by the function passed to $map as the second argument.

Reproduction: https://try.jsonata.org/hW13DjVzw

In case the link stops working at some point in the future, here is the inlined version of the reproduction steps:

Data

[{ "a": 1 }]

Jsonata

$map($, function($el) {
  { "a": $el.a + 1 }
})

Expected output

[{ "a": 2 }]

Actual output

{ "a": 2 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions