dbt-labs / dbt-labs/docs.getdbt.com
Listing and pretty-printing JSON output
- Dominant language
- JavaScript
- Stars
- 215
- Forks
- 1.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 130
Description
### Contributions
- [X] I have read the contribution docs, and understand what's expected of me.
### Link to the page on docs.getdbt.com requiring updates
https://docs.getdbt.com/reference/commands/list#example-usage
### What part(s) of the page would you like to see updated?
https://github.com/dbt-labs/dbt-core/issues/7660#issuecomment-1559357223 has a useful example using `json.tool` to pretty-print JSON formatted output. Although I prefer using [`jq`](https://stedolan.github.io/jq/) instead, `json.tool` is shipped along with Python, so it is quicker for most folks to use.
`json.tool` (and `jq`!) would be good to document in our docs to help people visualize their resource properties.
### `json.tool`
```shell
dbt -q ls --output json --resource-type source | python -m json.tool --json-lines
```
```json
{
"name": "some_table_1",
"resource_type": "source",
"package_name": "my_project_name",
"original_file_path": "models/some/very/deeply/nested/folder/_sources.yml",
"unique_id": "source.my_project_name.oba_postgres_public.some_table_1",
"source_name": "oba_postgres_public",
"tags": [],
"config": {
"enabled": true
}
}
{
"name": "some_table_2",
"resource_type": "source",
"package_name": "my_project_name",
"original_file_path": "models/some/very/deeply/nested/folder/_sources.yml",
"unique_id": "source.my_project_name.oba_postgres_secure_db.some_table_2",
"source_name": "oba_postgres_secure_db",
"tags": [],
"config": {
"enabled": true
}
}
```
### `jq`
Prerequisite: [install `jq`](https://stedolan.github.io/jq/download/)
```shell
dbt -q ls --output json --resource-type source | jq .
```
### Additional information
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.