https://github.com/quobject/cli-table-2-json
convert command line table output into json object
https://github.com/quobject/cli-table-2-json
Last synced: 8 months ago
JSON representation
convert command line table output into json object
- Host: GitHub
- URL: https://github.com/quobject/cli-table-2-json
- Owner: Quobject
- License: mit
- Created: 2015-11-23T19:02:10.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-04-28T15:53:46.000Z (almost 4 years ago)
- Last Synced: 2025-08-09T03:23:01.670Z (8 months ago)
- Language: TypeScript
- Size: 75.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cli-table-2-json
Convert command line table output into json object
[](https://nodei.co/npm/cli-table-2-json/)
[](https://nodei.co/npm/cli-table-2-json/)
## Installation
npm install cli-table-2-json
Then:
```js
var cliTable2Json = require('cli-table-2-json');
```
Usage:
```js
var lines = ['NAME ACTIVE DRIVER STATE URL SWARM',
'consul1 - amazonec2 Running tcp://54.175.200.212:2376 ',
'consul2 - amazonec2 Running tcp://52.23.236.38:2376 ',
'consul3 - amazonec2 Running tcp://54.85.111.241:2376 ',
''];
var result = cliTable2Json.cliTable2Json(lines);
console.log(result);
//[{
// name: 'consul1',
// active: '-',
// driver: 'amazonec2',
// state: 'Running',
// url: 'tcp://54.175.200.212:2376',
// swarm: ''
//},
// {
// name: 'consul2',
// active: '-',
// driver: 'amazonec2',
// state: 'Running',
// url: 'tcp://52.23.236.38:2376',
// swarm: ''
// },
// {
// name: 'consul3',
// active: '-',
// driver: 'amazonec2',
// state: 'Running',
// url: 'tcp://54.85.111.241:2376',
// swarm: ''
// }]
```
## Typescript
```
import { cliTable2Json } from 'cli-table-2-json';
var lines = ['NAME ACTIVE DRIVER STATE URL SWARM',
'consul1 - amazonec2 Running tcp://54.175.200.212:2376 ',
'consul2 - amazonec2 Running tcp://52.23.236.38:2376 ',
'consul3 - amazonec2 Running tcp://54.85.111.241:2376 ',
''];
var result = cliTable2Json(lines);
console.log(result);
```