Skip to content

[Feat] Sync JSON and CSV outputs of v.info -c to v.db.connect #6259

@wenzeslaus

Description

@wenzeslaus

JSON

JSON output of v.info with -c (print columns) is now a JSON object (dictionary) with a single key columns and the list of columns is nested under that. While this is a flexible way of structuring the JSON, the user/caller here already specified quite precisely what they want, namely a list of columns, so giving a list is the expected behavior.

My guess is that possible changes will more likely be resolved by other flags or a separate tool.

Current

grass --tmp-mapset ~/grassdata/nc_spm_08_grass7/ --exec v.info bridges -c format=json
{
    "columns": [
        {
            "name": "cat",
            "sql_type": "INTEGER",
            "is_number": true
        },
        {
            "name": "CO_NAME",
            "sql_type": "CHARACTER",
            "is_number": false
        }
    ]
}

Proposed

[
    {
        "name": "cat",
        "sql_type": "INTEGER",
        "is_number": true
    },
    {
        "name": "CO_NAME",
        "sql_type": "CHARACTER",
        "is_number": false
    }
]

CSV and shell

v.info with -c (print columns) and format=shell gives what is basically a CSV output. I suggests to add format=csv to v.info which would be now valid only with -c, while format=shell would not be valid with -c.

CSV should be the standard CSV, so comma as a separator and we also typically include header. This unfortunately means that for backwards compatibility, we need also an output without header and with pipe. This should be the same as for v.db.connect -c in #6077.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions