oclif/cli-ux

`table` incorrectly outputs number values as strings with `output : 'json'` option

Opened this issue · 2 comments

const data = [{
	name: 'bob',
	age: 32,
}];

console.log(JSON.stringify(data, undefined, 2));

cli.table(data, {
	name: {},
	age: {},
}, {output: 'json'});

Output:

[
  {
    "name": "bob",
    "age": 32
  }
]

[
  {
    "name": "bob",
    "age": "32"          <----- 
  }
]

To expand this, it would be awesome if we could have an option to write all source data if a machine-readable output format is used. If I print a table, I select a few, important columns to quickly get an overview. By selecting JSON or YAML, however, I'd like to get the full record with all columns and pipe that into other applications.
A simple solution would be an option to skip the header-wise serialization altogether.

+1 on this. It's not the end of the world to have a special case for outputting JSON where I handle calling JSON.stringify() myself, but it would be nice if cli.table could handle deeply-nested JSON objects as well.