Skip to content

[Feat] g.proj printing in json format for easier parsing #7812

Description

@baharmon

Is your feature request related to a problem? Please describe.

The GRASS Tools API is supposed to make parsing of tool output easier with Python, but it is now harder for g.proj. Flag g is depreciated and this module suggests using format=shell instead, but in Python that returns a ToolResult object that takes more work to parse. The ToolResult can be returned as a dictionary with method .keyval, but the manual page for this tool does not have an example of this.

# Find units with depreciated flag
projection = gs.parse_command("g.proj", flags=["g"])
units = projection.get("units", "units")
# Find units with shell
projection = tools.g_proj(format="shell", flags="p").keyval
units = projection.get("units")
print(units)

Describe the solution you'd like

I suggest adding a format=json option to g.proj for easier parsing. I also suggest adding up to date examples of parsing results with Python to the manual page.

# Find units with JSON
units = tools.g_proj(format="json", flags="p")["units"]
print(units)

Additional context
GRASS 8.5.0 (2026)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions