cli-ux icon indicating copy to clipboard operation
cli-ux copied to clipboard

`table` incorrectly outputs arrays with `output : 'json'` option

Open srlowe opened this issue 4 years ago • 0 comments

const data = [
   {
      a: 'a',
      b: [
         'b1',
         'b2'
      ]
   }
]

console.log(JSON.stringify(data, null, 2))

cli.table(
    data,
    ['a', 'b'],
    {output: 'json'}
);

Output:

[
  {
    "a": "a",
    "b": [
      "b1",
      "b2"
    ]
  }
]

[
  {
    "a": "a",
    "b": "[ 'b1', 'b2' ]" //<----  Array has been converted into a string.
  }
]

Relates to: https://github.com/oclif/cli-ux/issues/309

srlowe avatar Dec 08 '21 13:12 srlowe