Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v.info: add json output for columns #4590

Merged
merged 6 commits into from
Nov 5, 2024

Conversation

NishantBansal2003
Copy link
Contributor

Use parson to add json support to v.info for columns. The JSON output looks like as follows:

{
    "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
        }
    ]
}

fixes: #4218

@github-actions github-actions bot added vector Related to vector data processing Python Related code is in Python C Related code is in C module tests Related to Test Suite labels Oct 25, 2024
Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and it has a test for most of the functionality. Thanks!

vector/v.info/print.c Outdated Show resolved Hide resolved
vector/v.info/print.c Show resolved Hide resolved
Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments.

vector/v.info/print.c Outdated Show resolved Hide resolved
vector/v.info/print.c Outdated Show resolved Hide resolved
vector/v.info/print.c Show resolved Hide resolved
Signed-off-by: Nishant Bansal <[email protected]>
Signed-off-by: Nishant Bansal <[email protected]>
@nilason
Copy link
Contributor

nilason commented Oct 28, 2024

As print_columns() creates its own json objects, the following part in main:

if (format == JSON) {
root_value = json_value_init_object();
root_object = json_value_get_object(root_value);
}

may be moved down, before:

if ((shell_flag & SHELL_BASIC) || format == JSON) {
print_shell(&Map, field_opt, format, root_object);

@nilason
Copy link
Contributor

nilason commented Oct 29, 2024

Looks good to me now.

@nilason nilason added this to the 8.5.0 milestone Oct 29, 2024
@NishantBansal2003
Copy link
Contributor Author

NishantBansal2003 commented Oct 31, 2024

Could we move forward with this PR?
CC: @cwhite911 @wenzeslaus @echoix @petrasovaa

Any suggestions are welcome.

@petrasovaa
Copy link
Contributor

Looks like everything was addressed. I briefly tested it and looks good! Thank you @NishantBansal2003 !

@petrasovaa petrasovaa merged commit 039183d into OSGeo:main Nov 5, 2024
26 checks passed
@a0x8o a0x8o mentioned this pull request Nov 6, 2024
a0x8o pushed a commit to a0x8o/grass that referenced this pull request Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C module Python Related code is in Python tests Related to Test Suite vector Related to vector data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] Add JSON output for columns in v.info
4 participants