**Is your feature request related to a problem? Please describe.**
The use of… _c_ flag for _v.info_ should produce JSON with `format=json`:
```bash
grass --tmp-mapset ~/grassdata/nc_spm_08_grass7/ --exec v.info roadsmajor format=json -c
```
**Describe the solution you'd like**
JSON output which contains column names and metadata for these columns. Type is already in the current output, but there is more what could be included: other types of types (e.g., C versus SQL: [db_sqltype_to_Ctype](https://grass.osgeo.org/programming8/sqlCtype_8c.html#a1c02fe09d3c3d7632e4498494f3a1efc)) or some info on whether the column represents a number or whether it needs to be quoted in SQL (e.g., #1110).
**Describe alternatives you've considered**
The output could be a dictionary (mapping) or a list. In any case, the format should be extensible so more info can be included in the future. If a single column is a dictionary, then there is no problem with extending that. The question is if the list of columns should be in a dictionary.
Taking route of maximum flexibility:
```json
{
"columns": [
{
"name": "cat",
"sql_type": "INTEGER",
},
{
"name": "MAJORRDS_",
"sql_type": "DOUBLE PRECISION",
}
]
}
```
Flexible only for the individual columns (simpler, but (perhaps?) less common list as a first level):
```json
[
{
"name": "cat",
"sql_type": "INTEGER",
},
{
"name": "MAJORRDS_",
"sql_type": "DOUBLE PRECISION",
}
]
```
Shortest possible:
```json
[
{
"name": "cat",
"type": "INTEGER",
},
{
"name": "MAJORRDS_",
"type": "DOUBLE PRECISION",
}
]
```
I don't think we should do this:
```json
{
"names": ["cat", "MAJORRDS_"],
"types": ["INTEGER", "DOUBLE PRECISION"]
}
```
**Additional context**
The output should be similar, compatible and/or in sync with _v.db.select_:
```sh
$ grass --tmp-mapset ~/grassdata/nc_spm_08_grass7/ --exec v.db.select roadsmajor format=json | jq .info
```
```json
{
"columns": [
{
"name": "cat",
"sql_type": "INTEGER",
"is_number": true
},
{
"name": "MAJORRDS_",
"sql_type": "DOUBLE PRECISION",
"is_number": true
},
{
"name": "ROAD_NAME",
"sql_type": "CHARACTER",
"is_number": false
},
{
"name": "MULTILANE",
"sql_type": "CHARACTER",
"is_number": false
},
{
"name": "PROPYEAR",
"sql_type": "INTEGER",
"is_number": true
},
{
"name": "OBJECTID",
"sql_type": "INTEGER",
"is_number": true
},
{
"name": "SHAPE_LEN",
"sql_type": "DOUBLE PRECISION",
"is_number": true
}
]
}
```
Currently, the following is produced with the _c_ flag:
```
Displaying column types/names for database connection of layer <1>:
INTEGER|cat
DOUBLE PRECISION|MAJORRDS_
CHARACTER|ROAD_NAME
CHARACTER|MULTILANE
INTEGER|PROPYEAR
INTEGER|OBJECTID
DOUBLE PRECISION|SHAPE_LEN
```
(The `Displaying column ...` text goes to stderr and should not be produced for JSON.)
We do have tools which give lists, e.g., `g.gisenv get="GISDBASE,LOCATION_NAME,MAPSET" sep="comma"`, but once the output is more complex, list on the first level seems too limiting - I included also info about the columns to _v.db.select_ so that the full information about the type is preserved and can be used to, e.g., create a derived table.