> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cli.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Output Format

> How the CData CLI structures JSON output.

All CData CLI commands return results as JSON. By default, output is pretty-printed for readability. Use `--compact` anywhere to get single-line JSON, which is useful for piping to other tools.

## Query results

By default, the `query sql` command returns a JSON object with a single top-level key, `resultset`:

* **`resultset`** is an array containing the rows returned by the driver. Each row is an object whose keys are the column names.

Add the `--metadata` flag to include a second top-level key, `metadata`:

* **`metadata`** contains information about the columns returned. It is an array with one entry per column, describing the column's `label` and `name`, its type (`jdbcType` and `typeName`), nullability, precision, scale, display size, and the source `tableName`, `schemaName`, and `catalogName`.

```bash theme={null}
cdatacli query sql --connection "my-jira" --sql "SELECT Id, Summary FROM Issues LIMIT 2"
```

```json theme={null}
{
  "resultset" : [ {
    "Id" : 43147,
    "Summary" : "Add authentication options for enterprise customers"
  }, {
    "Id" : 43148,
    "Summary" : "Improve performance of the editor"
  } ]
}
```

## Including column metadata

Add `--metadata` to include the `metadata` array alongside the `resultset`:

```bash theme={null}
cdatacli query sql --connection "my-jira" --sql "SELECT Id, Summary FROM Issues LIMIT 2" --metadata
```

```json theme={null}
{
  "metadata" : [ {
    "index" : 1,
    "label" : "Id",
    "name" : "Id",
    "jdbcType" : 4,
    "typeName" : "INT",
    "nullable" : false,
    "precision" : 10,
    "scale" : 0,
    "displaySize" : 11,
    "tableName" : "Issues",
    "schemaName" : "JIRA",
    "catalogName" : "CData",
    "autoIncrement" : false,
    "readOnly" : true
  }, {
    "index" : 2,
    "label" : "Summary",
    "name" : "Summary",
    "jdbcType" : 12,
    "typeName" : "VARCHAR",
    "nullable" : false,
    "precision" : 2000,
    "scale" : 0,
    "displaySize" : 2000,
    "tableName" : "Issues",
    "schemaName" : "JIRA",
    "catalogName" : "CData",
    "autoIncrement" : false,
    "readOnly" : false
  } ],
  "resultset" : [ {
    "Id" : 43147,
    "Summary" : "Add authentication options for enterprise customers"
  }, {
    "Id" : 43148,
    "Summary" : "Improve performance of the editor"
  } ]
}
```

## Compact (single-line)

Add `--compact` to collapse the JSON onto a single line:

```bash theme={null}
cdatacli query sql --connection "my-jira" --sql "SELECT Id, Summary FROM Issues LIMIT 2" --compact
```

```json theme={null}
{"resultset":[{"Id":43147,"Summary":"Add authentication options for enterprise customers"},{"Id":43148,"Summary":"Improve performance of the editor"}]}
```

## Using with jq

The `--compact` flag makes it easy to pipe output to tools like [`jq`](https://jqlang.github.io/jq/). Use the `resultset` key to access the returned rows:

```bash theme={null}
cdatacli query sql --connection "my-jira" --sql "SELECT Id, Summary FROM Issues" --compact \
  | jq '.resultset[].Summary'
```
