2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: to json
|
|
|
|
layout: command
|
2022-03-04 13:10:09 +01:00
|
|
|
version: 0.59.1
|
2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
Converts table data into JSON text.
|
|
|
|
|
|
|
|
## Signature
|
|
|
|
|
2022-03-04 13:10:09 +01:00
|
|
|
```> to json --raw --indent --tabs```
|
2022-02-14 03:22:51 +01:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
- `--raw`: remove all of the whitespace
|
2022-02-21 18:26:00 +01:00
|
|
|
- `--indent {number}`: specify indentation width
|
2022-03-04 13:10:09 +01:00
|
|
|
- `--tabs {number}`: specify indentation tab quantity
|
2022-02-14 03:22:51 +01:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2022-02-21 18:26:00 +01:00
|
|
|
Outputs a JSON string, with default indentation, representing the contents of this table
|
|
|
|
```shell
|
|
|
|
> [a b c] | to json
|
|
|
|
```
|
|
|
|
|
|
|
|
Outputs a JSON string, with 4-space indentation, representing the contents of this table
|
2022-02-14 03:22:51 +01:00
|
|
|
```shell
|
2022-02-21 18:26:00 +01:00
|
|
|
> [Joe Bob Sam] | to json -i 4
|
2022-02-14 03:22:51 +01:00
|
|
|
```
|
|
|
|
|
2022-02-21 18:26:00 +01:00
|
|
|
Outputs an unformatted JSON string representing the contents of this table
|
|
|
|
```shell
|
|
|
|
> [1 2 3] | to json -r
|
|
|
|
```
|