Skip to content

Force nested arrays #399

@markmelville

Description

@markmelville

I've had no luck figuring out this nuance. I'm trying to convert data to a timeseries format required by another system. It wants the data as an array of arrays like this: http://try.jsonata.org/BkKNErBxL
Input:

[
  {"epochSeconds":1578381600,"value": 3},
  {"epochSeconds":1578381700,"value": 5}
]

Expression: $.[value,epochSeconds]
Result:

[
  [3,1578381600],
  [5,1578381700]
]

This is correct, but when there is only one item in the input array the result gets flattened.
Input:

[
  {"epochSeconds":1578381600,"value": 3}
]

Desired Output:

[
  [3,1578381600]
]

What I'm getting:

[
  3,
  1578381600
]

Is there some way to force an outer enclosing array when there is only one data point? TIA

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