{"id":15355064,"url":"https://github.com/adhocore/php-json-fixer","last_synced_at":"2025-07-14T04:34:22.774Z","repository":{"id":49147963,"uuid":"141589074","full_name":"adhocore/php-json-fixer","owner":"adhocore","description":"Fix truncated JSON data","archived":false,"fork":false,"pushed_at":"2024-01-20T09:20:40.000Z","size":53,"stargazers_count":49,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-14T15:27:25.191Z","etag":null,"topics":["adhocore","fix-json","fix-truncated-json","hacktoberfest","json","pad-json","php","recover-json","rectify-json"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/adhocore.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"adhocore","custom":["https://paypal.me/ji10"]}},"created_at":"2018-07-19T14:11:50.000Z","updated_at":"2024-02-26T14:29:22.000Z","dependencies_parsed_at":"2023-09-29T02:40:11.204Z","dependency_job_id":"e039245f-f12e-46bb-a2b0-92defea9adcb","html_url":"https://github.com/adhocore/php-json-fixer","commit_stats":{"total_commits":52,"total_committers":7,"mean_commits":7.428571428571429,"dds":0.25,"last_synced_commit":"3849208954a861cbb0f04628070d0e3ca0841be6"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/adhocore/php-json-fixer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-json-fixer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-json-fixer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-json-fixer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-json-fixer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adhocore","download_url":"https://codeload.github.com/adhocore/php-json-fixer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-json-fixer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259928368,"owners_count":22933368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["adhocore","fix-json","fix-truncated-json","hacktoberfest","json","pad-json","php","recover-json","rectify-json"],"created_at":"2024-10-01T12:22:21.063Z","updated_at":"2025-07-14T04:34:22.696Z","avatar_url":"https://github.com/adhocore.png","language":"PHP","readme":"## adhocore/json-fixer\n\nPHP library to fix Truncated JSON data by padding contextual counterpart to the end. Works with PHP5.4 or above.\n\n[![Latest Version](https://img.shields.io/github/release/adhocore/php-json-fixer.svg?style=flat-square)](https://github.com/adhocore/php-json-fixer/releases)\n[![Travis Build](https://travis-ci.com/adhocore/php-json-fixer.svg?branch=master)](https://travis-ci.com/adhocore/php-json-fixer?branch=master)\n[![Scrutinizer CI](https://img.shields.io/scrutinizer/g/adhocore/php-json-fixer.svg?style=flat-square)](https://scrutinizer-ci.com/g/adhocore/php-json-fixer/?branch=master)\n[![Codecov branch](https://img.shields.io/codecov/c/github/adhocore/php-json-fixer/master.svg?style=flat-square)](https://codecov.io/gh/adhocore/php-json-fixer)\n[![StyleCI](https://styleci.io/repos/141589074/shield)](https://styleci.io/repos/141589074)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Rescue+and+fix+truncated+JSON+data+in+PHP\u0026url=https://github.com/adhocore/php-json-fixer\u0026hashtags=php,json,jsonfixer,fixjson)\n[![Support](https://img.shields.io/static/v1?label=Support\u0026message=%E2%9D%A4\u0026logo=GitHub)](https://github.com/sponsors/adhocore)\n\u003c!-- [![Donate 15](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square\u0026label=donate+15)](https://www.paypal.me/ji10/15usd)\n[![Donate 25](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square\u0026label=donate+25)](https://www.paypal.me/ji10/25usd)\n[![Donate 50](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square\u0026label=donate+50)](https://www.paypal.me/ji10/50usd) --\u003e\n\n\n- Zero dependency (no vendor bloat).\n\n**It is a work in progress and might not cover all edge cases.** It would be great if you try it out, open some issues or contribute.\n\n## Installation\n```bash\ncomposer require adhocore/json-fixer\n```\n\n## Usage\n```php\nuse Ahc\\Json\\Fixer;\n\n$json = (new Fixer)-\u003efix('{\"a\":1,\"b\":2');\n// {\"a\":1,\"b\":2}\n\n$json = (new Fixer)-\u003efix('{\"a\":1,\"b\":true,');\n// {\"a\":1,\"b\":true}\n\n$json = (new Fixer)-\u003efix('{\"b\":[1,[{\"b\":1,\"c\"');\n// {\"b\":[1,[{\"b\":1,\"c\":null}]]}\n\n// For batch fixing, you can just reuse same fixer instance:\n$fixer = new Fixer;\n\n$fixer-\u003efix('...');\n$fixer-\u003efix('...');\n// ...\n```\n\n## Error\n\nIf there's error and fixer cant fix the JSON for some reason, it will throw a `RuntimeException`.\nYou can disable this behavior by passing silent flag (2nd param) to `fix()` in which case original input is returned:\n\n```php\n(new Fixer)-\u003esilent()-\u003efix('invalid');\n// 'invalid'\n\n(new Fixer)-\u003esilent(true)-\u003efix('invalid');\n// 'invalid'\n\n(new Fixer)-\u003esilent(false)-\u003efix('invalid');\n// RuntimeException\n```\n\n## Missing Value\n\nBy default missing values are padded with `null`. You can change it passing desired value to `missingValue()`:\n\n```php\n// key b is missing value and is padded with `null`\n$json = (new Fixer)-\u003efix('{\"a\":1,\"b\":');\n// {\"a\":1,\"b\":null}\n\n// key b is missing value and is padded with `true`\n$json = (new Fixer)-\u003emissingValue(true)-\u003efix('{\"a\":1,\"b\":');\n// {\"a\":1,\"b\":true}\n\n// key b is missing value and is padded with `\"truncated\"`\n// Note that you can actually inject a whole new JSON subset as 3rd param\n// but that should be a valid JSON segment and is not checked by fixer.\n$json = (new Fixer)-\u003emissingValue('\"truncated\"')-\u003efix('{\"a\":1,\"b\":');\n// {\"a\":1,\"b\":\"truncated\"}\n```\n\n## Todo\n\n- [ ] Configurable missing value as per context (options)\n","funding_links":["https://github.com/sponsors/adhocore","https://paypal.me/ji10","https://www.paypal.me/ji10/15usd","https://www.paypal.me/ji10/25usd","https://www.paypal.me/ji10/50usd"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhocore%2Fphp-json-fixer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadhocore%2Fphp-json-fixer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhocore%2Fphp-json-fixer/lists"}