{"id":51885504,"url":"https://github.com/olaflaitinen/laga","last_synced_at":"2026-07-25T20:03:56.997Z","repository":{"id":372933312,"uuid":"1310771552","full_name":"olaflaitinen/laga","owner":"olaflaitinen","description":"A fast, conservative JSON repair library for malformed model output, hand-written config, and almost-JSON text. Repairs common syntax issues and returns clean Python objects.","archived":false,"fork":false,"pushed_at":"2026-07-24T08:37:55.000Z","size":105,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-07-24T10:04:57.862Z","etag":null,"topics":["ai","cli","configuration","data-cleanup","json","json-parser","json-repair","llm","malformed-json","markdown","openai","parser","python","python-library","text-processing","trusted-publishing"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/laga/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olaflaitinen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-07-24T07:43:37.000Z","updated_at":"2026-07-24T10:01:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/olaflaitinen/laga","commit_stats":null,"previous_names":["olaflaitinen/laga"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/olaflaitinen/laga","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaflaitinen%2Flaga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaflaitinen%2Flaga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaflaitinen%2Flaga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaflaitinen%2Flaga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olaflaitinen","download_url":"https://codeload.github.com/olaflaitinen/laga/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olaflaitinen%2Flaga/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35891428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-25T02:00:06.922Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","cli","configuration","data-cleanup","json","json-parser","json-repair","llm","malformed-json","markdown","openai","parser","python","python-library","text-processing","trusted-publishing"],"created_at":"2026-07-25T20:03:56.387Z","updated_at":"2026-07-25T20:03:56.991Z","avatar_url":"https://github.com/olaflaitinen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laga\n\n`laga` repairs malformed JSON and returns Python objects.\n\nIt is built for the real world: model output, hand-written config, copied snippets, and other almost-JSON text that is usually close enough to recover but not strict enough for `json.loads`.\n\n## Highlights\n\n- Repairs common JSON mistakes such as trailing commas, missing commas, single quotes, unquoted keys, comments, fences, smart quotes, and truncated containers.\n- Tries the standard library first, so valid JSON stays fast and strict.\n- Keeps the public API small: `repair`, `repair_to_str`, `loads`, and `LagaError`.\n- Ships with a CLI, JSONL support, type information, tests, docs, and CI.\n\n## Supported Versions\n\n`laga` 0.1.6 supports Python 3.10 through 3.13.\n\n## Install\n\nFor normal use from PyPI:\n\n```bash\npython -m pip install laga\n```\n\nFor local development from a checkout:\n\n```bash\npython -m pip install -e \".[dev]\"\n```\n\n## Quick Start\n\n```python\nimport laga\n\ntext = \"{name: 'Ada', active: True, roles: ['admin', 'writer',],}\"\n\ndata = laga.repair(text)\nprint(data)\nprint(laga.repair_to_str(text))\n```\n\n## CLI\n\nYou can also use `laga` from the command line:\n\n```bash\nlaga \"{name: 'Ada', active: True, roles: ['admin',]}\"\nlaga --strict '{\"a\": 1,}'\n```\n\nUse `--strict` when you want to reject ambiguous repairs instead of filling in gaps.\nUse `--pretty` to format output for humans, `--stdin` to read from standard input, and `--duplicate-keys error` when duplicate keys should fail.\nUse `--input` to read from a file, `--output` to write the repaired result back to disk, or `--in-place` to overwrite the input file directly.\nUse `--jsonl` when each non-empty line is a separate JSON record and you want one repaired value per line.\n\n```bash\nlaga --stdin --pretty\nlaga --input sample.txt --output fixed.json\nlaga --input sample.txt --in-place --pretty\nlaga --jsonl --stdin\nlaga --max-depth 64 --max-input-size 10000 --duplicate-keys error '{\"a\": 1}'\n```\n\n## API\n\n| Function | Returns | Description |\n| --- | --- | --- |\n| `laga.repair(text, strict=False)` | Python object | Repairs malformed JSON and returns Python data. |\n| `laga.repair_to_str(text, strict=False)` | `str` | Repairs malformed JSON and returns normalized JSON text. |\n| `laga.repair_jsonl(text, strict=False)` | `list[object]` | Repairs newline-delimited JSON records and returns Python values. |\n| `laga.repair_jsonl_to_str(text, strict=False)` | `str` | Repairs newline-delimited JSON records and returns newline-delimited JSON text. |\n| `laga.repair_file(path, strict=False)` | Python object | Reads a file and repairs its contents. |\n| `laga.loads(text, strict=False)` | Python object | Alias for `laga.repair`. |\n| `laga.LagaError` | Exception type | Raised when repair fails or input is unrecoverable. |\n\n## What It Repairs\n\n| Rule | Before | After |\n| --- | --- | --- |\n| Trailing comma | `{\"a\": 1,}` | `{\"a\":1}` |\n| Missing comma | `{\"a\": 1 \"b\": 2}` | `{\"a\":1,\"b\":2}` |\n| Single quotes | `{'a': 'b'}` | `{\"a\":\"b\"}` |\n| Unquoted keys | `{name: \"Ada\"}` | `{\"name\":\"Ada\"}` |\n| Python literals | `{\"ok\": True, \"none\": None}` | `{\"ok\":true,\"none\":null}` |\n| Comments | `{\"a\": 1 // note\\n}` | `{\"a\":1}` |\n| Markdown fences | \u003ccode\u003e```json\\n{\"a\":1}\\n```\u003c/code\u003e | `{\"a\":1}` |\n| Smart quotes | `“a”` | `\"a\"` |\n| Prose around JSON | `Result: {\"a\":1}` | `{\"a\":1}` |\n| Truncated structure | `{\"a\": [1, 2` | `{\"a\":[1,2]}` |\n\n## Strict Mode\n\n`strict=True` is for validation workflows where you want `laga` to fail instead of guessing.\n\nIn strict mode, `laga` rejects ambiguous recoveries such as:\n\n- missing commas between object members or array items\n- unterminated objects or arrays\n- other repairs that would require filling in structure the input did not clearly provide\n\n## Behavior Notes\n\n- `json.loads` is still the best choice when you control the producer and the input is already valid JSON.\n- Duplicate keys use last-value-wins behavior, matching Python dict semantics.\n- Use `duplicate_keys=\"error\"` when you want duplicate object members to fail instead of being merged.\n- `laga` does not evaluate expressions or try to invent arbitrary JavaScript syntax.\n- The parser is intentionally conservative around malformed numbers and highly ambiguous text.\n\n## Quick Decision Guide\n\n| Situation | Best choice |\n| --- | --- |\n| You control the producer and the input is valid JSON | `json.loads` |\n| You have noisy LLM output, copied config, or prose around JSON | `laga.repair` |\n| You have JSONL or line-delimited records to repair | `laga.repair_jsonl` |\n| You need to repair a file directly | `laga.repair_file` |\n| You want duplicate keys to fail | `duplicate_keys=\"error\"` |\n| You want a human-friendly result | `repair_to_str(..., pretty=True)` |\n\n## When To Use `laga`\n\nUse `laga` when the input is noisy, user-facing, or generated by a model and you need a predictable repair step before parsing.\n\nUse `json.loads` when correctness and strictness matter more than recovery.\n\n## Development\n\n```bash\nmake install\nmake lint\nmake typecheck\nmake test\nmake build\n```\n\n## Project Links\n\n- Documentation: [docs/index.md](docs/index.md)\n- API details: [docs/api.md](docs/api.md)\n- Usage examples: [docs/usage.md](docs/usage.md)\n- Contributing guide: [CONTRIBUTING.md](CONTRIBUTING.md)\n\n## Citation\n\nIf you use `laga` in academic work, research notes, or other formal writing, please cite the repository using the metadata in [CITATION.cff](CITATION.cff).\n\nSuggested citation format:\n\n```text\nLaitinen-Fredriksson Lundström-Imanov, G. O. Y. (2026). laga (Version 0.1.6) [Computer software]. https://github.com/olaflaitinen/laga\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaflaitinen%2Flaga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folaflaitinen%2Flaga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folaflaitinen%2Flaga/lists"}