{"id":18767460,"url":"https://github.com/codekandis/json-codec","last_synced_at":"2026-02-03T12:32:42.775Z","repository":{"id":56955190,"uuid":"201785661","full_name":"codekandis/json-codec","owner":"codekandis","description":"`codekandis/json-codec` is a library to encode into and decode from JSON data in an object oriented way. It wraps PHP's functions `json_encode()` and `json_decode()`.","archived":false,"fork":false,"pushed_at":"2024-08-06T21:30:30.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T14:01:43.493Z","etag":null,"topics":["codec","decoder","encoder","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/codekandis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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-08-11T16:00:06.000Z","updated_at":"2024-08-06T21:33:25.000Z","dependencies_parsed_at":"2024-02-17T15:27:54.124Z","dependency_job_id":"27a8a69b-a8bd-4561-8c33-8cf7bf874b93","html_url":"https://github.com/codekandis/json-codec","commit_stats":{"total_commits":24,"total_committers":1,"mean_commits":24.0,"dds":0.0,"last_synced_commit":"991f5f0c7e08e8272c14c84a99c1e63613306029"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekandis%2Fjson-codec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekandis%2Fjson-codec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekandis%2Fjson-codec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekandis%2Fjson-codec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codekandis","download_url":"https://codeload.github.com/codekandis/json-codec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246314150,"owners_count":20757463,"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":["codec","decoder","encoder","json","php"],"created_at":"2024-11-07T19:07:31.289Z","updated_at":"2026-02-03T12:32:37.744Z","avatar_url":"https://github.com/codekandis.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# codekandis/json-codec\n\n[![Version][xtlink-version-badge]][srclink-changelog]\n[![License][xtlink-license-badge]][srclink-license]\n[![Minimum PHP Version][xtlink-php-version-badge]][xtlink-php-net]\n![Code Coverage][xtlink-code-coverage-badge]\n\nWith the JSON codec you will be able to encode into and decode from JSON data in an object oriented way. It wraps PHP's functions [`json_encode()`][xtlink-php-net-json-encode] and [`json_decode()`][xtlink-php-net-json-decode].\n\n## Index\n\n* [Installation](#installation)\n* [How to use](#how-to-use)\n  * [Encoding values](#encoding-values)\n  * [Decoding values](#decoding-values)\n* [Differences to PHP's JSON functions](#differences-to-phps-json-functions)\n\n## Installation\n\nInstall the latest version with\n\n```bash\n$ composer require codekandis/json-codec\n```\n\n## How to use\n\n### Encoding values\n\nThe following example shows how to encode a value.\n\n```php\n$value = [\n  'foo',\n  'bar'\n];\n\n( new JsonEncoder() )\n  -\u003eencode( $value );\n\n$options = new JsonEncoderOptions( JsonEncoderOptions::FORCE_OBJECT | JsonEncoderOptions::PRETTY_PRINT );\n( new JsonEncoder() )\n  -\u003eencode( $value, $options );\n```\n\n### Decoding values\n\nThe following examples show how to decode a value.\n\n```php\n$value = '{\"0\":\"foo\",\"1\":\"bar\"}';\n\n( new JsonDecoder() )\n  -\u003edecode( $value );\n\n$options = new JsonDecoderOptions( JsonDecoderOptions::OBJECT_AS_ARRAY );\n( new JsonDecoder() )\n  -\u003edecode( $value, $options );\n\n$options        = new JsonDecoderOptions( JsonDecoderOptions::OBJECT_AS_ARRAY );\n$recursionDepth = 2;\n( new JsonDecoder() )\n  -\u003edecode( $value, $options, $recursionDepth );\n```\n\n## Differences to PHP's JSON functions\n\n[`json_decode()`][xtlink-php-net-json-encode] accepts an additional argument [`$assoc`][xtlink-php-net-json-decode-arguments] to specify if the value forced to be decoded into an associative array. This argument is omitted in the [`JsonDecoder`][srclink-json-decoder] while this behaviour can be set explicitly with the [`JsonDecoderOptions::OBJECT_TO_ARRAY`][srclink-json-decoder-options].\n\n\n\n[xtlink-version-badge]: https://img.shields.io/badge/version-3.0.0-blue.svg\n[xtlink-license-badge]: https://img.shields.io/badge/license-MIT-yellow.svg\n[xtlink-php-version-badge]: https://img.shields.io/badge/php-%3E%3D%208.3-8892BF.svg\n[xtlink-code-coverage-badge]: https://img.shields.io/badge/coverage-100%25-green.svg\n[xtlink-php-net]: https://php.net\n[xtlink-php-net-json-encode]: https://www.php.net/manual/en/function.json-encode.php\n[xtlink-php-net-json-decode]: https://www.php.net/manual/en/function.json-decode.php\n[xtlink-php-net-json-decode-arguments]: https://www.php.net/manual/en/function.json-decode.php#refsect1-function.json-decode-parameters\n\n[srclink-changelog]: ./CHANGELOG.md\n[srclink-license]: ./LICENSE\n[srclink-json-decoder]: ./src/JsonDecoder.php\n[srclink-json-decoder-options]: ./src/JsonDecoderOptions.php\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodekandis%2Fjson-codec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodekandis%2Fjson-codec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodekandis%2Fjson-codec/lists"}