{"id":9796,"library":"gron","title":"Python Gron","description":"`gron` is a Python library and command-line tool that transforms JSON into a more \"greppable\" format, where each field is represented as a distinct, path-based line, making it easier to search and manipulate. It also provides functionality to convert the \"gron\" format back to JSON. The current version is 1.4.0, and it sees active development with minor feature releases.","status":"active","version":"1.4.0","language":"en","source_language":"en","source_url":"https://github.com/venthur/python-gron","tags":["json","cli","data transformation","flattening","greppable"],"install":[{"cmd":"pip install gron","lang":"bash","label":"Install gron"}],"dependencies":[],"imports":[{"note":"The main library module is named 'gron'.","symbol":"gron","correct":"import gron"},{"note":"For direct access to the JSON to gron conversion function.","symbol":"json_to_gron","correct":"from gron import json_to_gron"},{"note":"For direct access to the gron to JSON conversion function.","symbol":"gron_to_json","correct":"from gron import gron_to_json"}],"quickstart":{"code":"import gron\nimport json\n\ndata = {'name': 'Alice', 'age': 30, 'address': {'street': '123 Main St', 'city': 'Anytown'}}\njson_string = json.dumps(data, indent=2)\n\n# Convert JSON to gron format\ngron_output = gron.json_to_gron(json_string)\nprint(\"--- Gron Output ---\")\nprint(gron_output)\n\n# Example gron string (usually from json_to_gron output)\ngron_lines = \"\"\"\njson = {};\njson.name = \"Alice\";\njson.age = 30;\njson.address = {};\njson.address.street = \"123 Main St\";\njson.address.city = \"Anytown\";\n\"\"\"\n\n# Convert gron format back to JSON\njson_back = gron.gron_to_json(gron_lines)\nprint(\"\\n--- JSON Back ---\")\nprint(json.dumps(json_back, indent=2))","lang":"python","description":"This quickstart demonstrates how to convert a Python dictionary (serialized to JSON) into the `gron` format, and then how to convert a `gron` formatted string back into a Python dictionary, showcasing the core library functions."},"warnings":[{"fix":"Ensure the input string for `gron_to_json` is valid `gron` output or manually constructed using the correct syntax. Pay attention to semicolons, `json = {};` initialization, and proper pathing.","message":"The `gron_to_json` function expects input strictly adhering to the `gron` format (e.g., `json.key = \"value\";`). Malformed gron strings or non-gron input will result in parsing errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Understand that `gron`'s purpose is flattening JSON for greppability. To revert to a hierarchical JSON structure, you must use `gron_to_json` on the `gron` output.","message":"The `gron` format flattens nested JSON objects and arrays into individual, path-based lines. Users expecting a re-structured but still hierarchical JSON output from `json_to_gron` will find the output is primarily for line-by-line processing.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Ensure `pip install gron` is successful and you are importing the `gron` module, then accessing its functions via `gron.json_to_gron()` and `gron.gron_to_json()`. Verify the installed version with `pip show gron`.","cause":"The `gron` library was installed but the functions are not being accessed correctly, or an older version without these functions might be installed, or another module is shadowing the `gron` name.","error":"AttributeError: module 'gron' has no attribute 'json_to_gron'"},{"fix":"Review the `gron` input string for syntax errors, such as missing semicolons, incorrect value assignments, unquoted strings that should be quoted, or invalid path definitions. The `gron` format is strict.","cause":"The input string provided to `gron.gron_to_json()` does not conform to the expected `gron` syntax.","error":"gron.exceptions.GronParsingError: Unable to parse gron input at line X (e.g., at 'unexpected token Y')"}]}