{"id":21328166,"url":"https://github.com/hampel/json","last_synced_at":"2026-04-29T15:01:56.846Z","repository":{"id":173874866,"uuid":"651417790","full_name":"hampel/json","owner":"hampel","description":"A simple wrapper for json_encode and json_decode with exception based error handling","archived":false,"fork":false,"pushed_at":"2023-06-10T01:52:53.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-25T10:44:16.130Z","etag":null,"topics":["json","php"],"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/hampel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-06-09T07:38:04.000Z","updated_at":"2023-06-09T13:02:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"7ecdb14e-ffed-4915-b4f4-693c3782d41a","html_url":"https://github.com/hampel/json","commit_stats":null,"previous_names":["hampel/json"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/hampel/json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hampel%2Fjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hampel%2Fjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hampel%2Fjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hampel%2Fjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hampel","download_url":"https://codeload.github.com/hampel/json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hampel%2Fjson/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260424571,"owners_count":23007035,"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":["json","php"],"created_at":"2024-11-21T21:24:41.681Z","updated_at":"2026-04-29T15:01:51.822Z","avatar_url":"https://github.com/hampel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"JSON Wrapper\n============\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/hampel/json.svg?style=flat-square)](https://packagist.org/packages/hampel/json)\n[![Total Downloads](https://img.shields.io/packagist/dt/hampel/json.svg?style=flat-square)](https://packagist.org/packages/hampel/json)\n[![Open Issues](https://img.shields.io/github/issues-raw/hampel/json.svg?style=flat-square)](https://github.com/hampel/json/issues)\n[![License](https://img.shields.io/packagist/l/hampel/json.svg?style=flat-square)](https://packagist.org/packages/hampel/json)\n\nA simple wrapper for `json_encode` and `json_decode` with exception based error handling\n\nBy [Simon Hampel](mailto:simon@hampelgroup.com)\n\n__Note:__ as of PHP v7.3 there is now a `JSON_THROW_ON_ERROR` option for both native commands which should effectively\nrender this package obsolete.\n\nInstallation\n------------\n\nTo install using composer, run the following command:\n\n`composer require hampel/json`\n\nNote that there are three versions of this package, depending on the version of PHP you use:\n\n* v2.1 supports PHP \u003e= v5.3.3\n* v2.2 supports PHP \u003e= v5.4.0\n* v2.3 supports PHP \u003e= v5.5.0\n\nThe three versions will be maintained in parallel\n    \nUsage\n-----\n\nAll parameters are the same as specified for the PHP functions json_encode and json_decode respectively.\n\nThe main difference that this class provides is that it throws exceptions when there are errors and translates the\nerror codes into meaningful text for you automatically.\n\n```php\n\u003c?php\n\nuse Hampel\\Json\\Json;\nuse Hampel\\Json\\JsonException;\n\n$data = array('a' =\u003e 1, 'b' =\u003e 2, 'c' =\u003e 3, 'd' =\u003e 4, 'e' =\u003e 5);\n\n// Encode a variable as JSON:\necho Json::encode($data);\n\n// Encode options\n$options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP;\necho Json::encode($data, $options);\n\n// Decode JSON:\nprint_r(Json::decode('{\"a\":1,\"b\":2,\"c\":3,\"d\":4,\"e\":5}'));\n\n// Error handling\ntry {\n    Json::decode('{\"a\":1,\"b\":2,\"c\":3,\"d\":4,\"e\":5'); // missing }\n} catch (JsonException $e) {\n    echo \"Oops: \" . $e-\u003egetMessage();\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhampel%2Fjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhampel%2Fjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhampel%2Fjson/lists"}