{"id":15543458,"url":"https://github.com/gromnan/php-crunch-json","last_synced_at":"2026-04-19T02:05:03.709Z","repository":{"id":62512816,"uuid":"131953109","full_name":"GromNaN/php-crunch-json","owner":"GromNaN","description":"Optimizes JSON responses by minimizing duplication and improving compressibility.","archived":false,"fork":false,"pushed_at":"2018-07-14T21:31:48.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-19T03:56:07.842Z","etag":null,"topics":["json","json-crunch","php-library"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GromNaN.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-03T06:44:54.000Z","updated_at":"2024-05-05T23:18:48.000Z","dependencies_parsed_at":"2022-11-02T12:47:27.024Z","dependency_job_id":null,"html_url":"https://github.com/GromNaN/php-crunch-json","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/GromNaN/php-crunch-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GromNaN%2Fphp-crunch-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GromNaN%2Fphp-crunch-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GromNaN%2Fphp-crunch-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GromNaN%2Fphp-crunch-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GromNaN","download_url":"https://codeload.github.com/GromNaN/php-crunch-json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GromNaN%2Fphp-crunch-json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272233329,"owners_count":24896788,"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","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"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":["json","json-crunch","php-library"],"created_at":"2024-10-02T12:27:09.766Z","updated_at":"2026-04-19T02:05:03.664Z","avatar_url":"https://github.com/GromNaN.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"PHP implementation of the node module [`graphql-crunch`](https://github.com/banterfm/graphql-crunch#readme).\n\n\u003e Optimizes JSON responses by minimizing duplication and improving compressibility.\n\nInstallation\n------------\n\n```\ncomposer require gromnan/json-crunch\n```\n\nHow does it work?\n-----------------\n\n\u003e We flatten the object hierarchy into an array using a post-order traversal of the object graph. As we traverse we efficiently check if we've come across a value before, including arrays and objects, and replace it with a reference to it's earlier occurence if we've seen it. Values are only ever present in the array once.\n\nUsage\n-----\n\n```php\nuse function GromNaN\\JsonCrunch\\crunch;\n\n$data = json_decode('{\"a\":[\"a\",\"b\",\"a\"],\"b\":[\"a\",\"b\",\"a\"]}');\n\n$crunched = crunch($data);\n\necho json_encode($data, JSON_PRETTY_PRINT);\n```\n\nResult:\n```json\n[\n    \"a\",\n    \"b\",\n    [0,1,0],\n    {\"a\":2,\"b\":2}\n]\n```\n\nCommand-line\n------------\n\n```\nbin/crunch-json \u003cfile\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgromnan%2Fphp-crunch-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgromnan%2Fphp-crunch-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgromnan%2Fphp-crunch-json/lists"}