{"id":13623778,"url":"https://github.com/JsonMapper/JsonMapper","last_synced_at":"2025-04-15T20:32:21.836Z","repository":{"id":37825791,"uuid":"245258310","full_name":"JsonMapper/JsonMapper","owner":"JsonMapper","description":"Map nested JSON structures to PHP classes","archived":false,"fork":false,"pushed_at":"2024-05-14T09:29:22.000Z","size":494,"stargazers_count":210,"open_issues_count":6,"forks_count":26,"subscribers_count":7,"default_branch":"develop","last_synced_at":"2024-10-31T09:12:01.612Z","etag":null,"topics":["hacktoberfest","hydration","json","jsonmapper","mapper","mapping","middleware","php"],"latest_commit_sha":null,"homepage":"https://jsonmapper.net","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/JsonMapper.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["DannyvdSluijs"]}},"created_at":"2020-03-05T20:12:50.000Z","updated_at":"2024-10-02T07:16:34.000Z","dependencies_parsed_at":"2023-12-12T12:26:17.675Z","dependency_job_id":"79cb6240-1190-4525-ab01-0536d3511fa4","html_url":"https://github.com/JsonMapper/JsonMapper","commit_stats":{"total_commits":164,"total_committers":10,"mean_commits":16.4,"dds":"0.054878048780487854","last_synced_commit":"835282ba405bf70bfa42455e4fa758ad71a0b55a"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JsonMapper%2FJsonMapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JsonMapper%2FJsonMapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JsonMapper%2FJsonMapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JsonMapper%2FJsonMapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JsonMapper","download_url":"https://codeload.github.com/JsonMapper/JsonMapper/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222736175,"owners_count":17030832,"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":["hacktoberfest","hydration","json","jsonmapper","mapper","mapping","middleware","php"],"created_at":"2024-08-01T21:01:35.523Z","updated_at":"2025-04-15T20:32:21.822Z","avatar_url":"https://github.com/JsonMapper.png","language":"PHP","readme":"\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://jsonmapper.net/images/jsonmapper-light.png\"\u003e\n  \u003cimg alt=\"JsonMapper logo\" src=\"https://jsonmapper.net/images/jsonmapper.png\"\u003e\n\u003c/picture\u003e\n\n---\nJsonMapper is a PHP library that allows you to map a JSON response to your PHP objects that are either annotated using doc blocks or use typed properties.\nFor more information see the project website: https://jsonmapper.net/\n\n[![GitHub](https://img.shields.io/github/license/JsonMapper/JsonMapper)](https://choosealicense.com/licenses/mit/)\n[![Packagist Version](https://img.shields.io/packagist/v/json-mapper/json-mapper)](https://packagist.org/packages/json-mapper/json-mapper)\n![Packagist Downloads](https://img.shields.io/packagist/dm/json-mapper/json-mapper)\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/json-mapper/json-mapper)](#)\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/JsonMapper/JsonMapper/build.yaml)\n[![Coverage Status](https://coveralls.io/repos/github/JsonMapper/JsonMapper/badge.svg?branch=develop)](https://coveralls.io/github/JsonMapper/JsonMapper?branch=develop)\n\n# Why use JsonMapper\nContinuously mapping your JSON responses to your own objects becomes tedious and is error-prone. Not mentioning the\ntests that needs to be written for said mapping.\n\nJsonMapper has been build with the most common usages in mind. In order to allow for those edge cases which are not \nsupported by default, it can easily be extended as its core has been designed using middleware.\n\nJsonMapper supports the following features\n * Case conversion\n * Debugging\n * DocBlock annotations\n * Final callback\n * Namespace resolving\n * PHP 7.4 Types properties\n  \n# Installing JsonMapper\nThe installation of JsonMapper can easily be done with [Composer](https://getcomposer.org)\n```bash\n$ composer require json-mapper/json-mapper\n```\nThe example shown above assumes that `composer` is on your `$PATH`.\n\n# How do I use JsonMapper\nGiven the following class definition\n```php\nnamespace JsonMapper\\Tests\\Implementation;\n\nclass SimpleObject\n{\n    /** @var string */\n    private $name;\n\n    public function getName(): string\n    {\n        return $this-\u003ename;\n    }\n\n    public function setName(string $name): void\n    {\n        $this-\u003ename = $name;\n    }\n}\n```\nCombined with the following JsonMapper code as part of your application\n```php\n$mapper = (new \\JsonMapper\\JsonMapperFactory())-\u003edefault();\n$object = new \\JsonMapper\\Tests\\Implementation\\SimpleObject();\n\n$mapper-\u003emapObject(json_decode('{ \"name\": \"John Doe\" }'), $object);\n\nvar_dump($object);\n```\nThe above example will output:\n```text\nclass JsonMapper\\Tests\\Implementation\\SimpleObject#1 (1) {\n  private $name =\u003e\n  string(8) \"John Doe\"\n}\n```  \n\n# Customizing JsonMapper\nWriting your own middleware has been made as easy as possible with an `AbstractMiddleware` that can be extended with the functionality \nyou need for your project.\n\n```php\nuse JsonMapper;\n\n$mapper = (new JsonMapper\\JsonMapperFactory())-\u003ebestFit();\n$mapper-\u003epush(new class extends JsonMapper\\Middleware\\AbstractMiddleware {\n    public function handle(\n        \\stdClass $json,\n        JsonMapper\\Wrapper\\ObjectWrapper $object,\n        JsonMapper\\ValueObjects\\PropertyMap $map,\n        JsonMapper\\JsonMapperInterface $mapper\n    ): void {\n        /* Custom logic here */\n    }\n});\n```\n\n# Contributing\nPlease refer to [CONTRIBUTING.md](https://github.com/JsonMapper/JsonMapper/blob/main/CONTRIBUTING.md) for information on how to contribute to JsonMapper.\n\n## List of Contributors\nThanks to everyone who has contributed to JsonMapper! You can find a detailed list of contributors of JsonMapper on [GitHub](https://github.com/JsonMapper/JsonMapper/graphs/contributors).\n\n## Sponsoring\n[![JetBrains](https://jsonmapper.net/images/jetbrains-variant-3.png?)](https://www.jetbrains.com/?from=JsonMapper)\n\nThis project is sponsored by JetBrains providing an open source license to continue building on JsonMapper without cost.     \n\n# License\nThe MIT License (MIT). Please see [License File](https://github.com/JsonMapper/JsonMapper/blob/main/LICENSE) for more information.\n","funding_links":["https://github.com/sponsors/DannyvdSluijs"],"categories":["目录","Table of Contents","PHP"],"sub_categories":["JSON"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJsonMapper%2FJsonMapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJsonMapper%2FJsonMapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJsonMapper%2FJsonMapper/lists"}