{"id":13576914,"url":"https://github.com/half-pie/half-json","last_synced_at":"2026-01-14T08:16:23.945Z","repository":{"id":57436626,"uuid":"185642261","full_name":"half-pie/half-json","owner":"half-pie","description":"auto fix  invalid json  / 自动修复补全残缺无效的 JSON","archived":false,"fork":false,"pushed_at":"2023-11-16T15:40:07.000Z","size":97,"stargazers_count":60,"open_issues_count":3,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-25T10:34:03.933Z","etag":null,"topics":["broken-json","fix-invalid-json","fix-json","fix-truncated-json","jsonfixer"],"latest_commit_sha":null,"homepage":"","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/half-pie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-08T16:24:47.000Z","updated_at":"2025-09-17T21:16:48.000Z","dependencies_parsed_at":"2025-04-05T09:40:37.866Z","dependency_job_id":null,"html_url":"https://github.com/half-pie/half-json","commit_stats":{"total_commits":71,"total_committers":2,"mean_commits":35.5,"dds":"0.014084507042253502","last_synced_commit":"d8064e90ac769547c22db11bcbe47fcb4f1eb600"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/half-pie/half-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/half-pie%2Fhalf-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/half-pie%2Fhalf-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/half-pie%2Fhalf-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/half-pie%2Fhalf-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/half-pie","download_url":"https://codeload.github.com/half-pie/half-json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/half-pie%2Fhalf-json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28413747,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["broken-json","fix-invalid-json","fix-json","fix-truncated-json","jsonfixer"],"created_at":"2024-08-01T15:01:15.823Z","updated_at":"2026-01-14T08:16:23.924Z","avatar_url":"https://github.com/half-pie.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Install\n\n```bash\npip install jsonfixer\n```\n# Usage\n\n```python\nIn [1]: from half_json.core import JSONFixer\n\nIn [2]: f = JSONFixer()\n\nIn [3]: f.fix('[{')\nOut[3]: FixResult(success=True, line='[{}]', origin=False)\n\nIn [4]: f.fix('{\"a')\nOut[4]: FixResult(success=True, line='{\"a\":null}', origin=False)\n\nIn [5]: f.fix('{\"a\":}')\nOut[5]: FixResult(success=True, line='{\"a\":null}', origin=False)\n```\n\n## 目标\n\nfix invalid/broken/truncated json\n\n# 修复原理\n\n1. JSONDecoderError\n2. line context\n\n## HitRatio\n\n根据 checks 里面的工具来衡量修改效果\n\nABC : autogen --\u003e broken --\u003e check\nTSR : run test.sh show.sh ratio.sh\n\n### FixRatio\n\n仅判断 result.success == True\n\n```bash\n./runratio.sh fix\n```\n```\n1.  0.4269, 0.4287, 0.4303   # 实现完 12 条规则\n2.  0.5037, 0.5084, 0.5077   # string 的 \" 补充在末尾\n3.  0.5259, 0.5224, 0.5187   # Array 需要 pos - 2\n4.  0.5433, 0.5311, 0.5381   # Array 细化一下 [, 的情况\n5.  0.7192, 0.7216, 0.7265   # 大改进, FIX 之前的 Bug( parser 被冲掉了)\n6.  0.7732, 0.7686, 0.7701   # case: {\"a\":1 --\u003e 补充 }\n7.  0.60  , 0.58             # 去掉了空行\n8.  0.6971, 0.6969, 0.6984   # 增加处理 StopIteration\n9.  0.7428, 0.7383, 0.7427   # 增加处理 half parse\n10. 0.7617, 0.7631, 0.7558   # 细化处理 half parse\n11. 0.7608, 0.7612, 0.7650   # 添加从左处理\n12. 0.9817, 0.9827, 0.9819   # 增加对字符串的处理\n13. 0.8314, 0.8302, 0.8312   # 去掉对字符串的额外处理\n14. 0.95X                    # 已不可参考\n```\n\n### Real HitRatio\n\n判断 result.success == True\n\n并且解析后的 json 大体和原来一致(equal \u0026\u0026 dictdiffer)\n\n```bash\n./runratio.sh hit\n```\n```\n1. 0.5610, 0.5563, 0.5529   # origin\n2. 0.5593, 0.5532, 0.5587   # fix :} --\u003e :null}\n```\n\n# TODO\n\n## 目前的缺点 \u0026\u0026 发现\n\n3. 数字的支持比较弱 --\u003e -02 / 0. / .0\n4. 还不支持分支回溯 --\u003e [{]\n7. 突然想到, 应该反思一下, 这个是一个fixer, 而不是一个将任何字符串都转为 json 的东西\n   应该明确 JSONFixer 的能力范围, 对 runratio.sh 也应该比较前后两个的 json 相似程度。\n   (听起来像无能者的辩白?)\n8. 也需要吧 parser 也做成 stack 这样可以解决 [\"a] --\u003e [\"a\"] 这样的 case\n\n1. 考虑分支回溯的方式来试探\n2. 解析缺失的 JSON 常量\n9.\n\n## BadCase\n1. 1- --\u003e {\"1-\": null}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalf-pie%2Fhalf-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalf-pie%2Fhalf-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalf-pie%2Fhalf-json/lists"}