A PHP library that maps nested JSON structures to PHP classes using doc blocks or typed properties.
JsonMapper is a PHP library that automates the mapping of JSON responses to PHP objects. It eliminates the tedious and error-prone process of manual mapping, saving development time and reducing the need for extensive test coverage. The library supports both doc block annotations and PHP 7.4 typed properties, making it versatile for modern PHP applications.
PHP developers working with APIs or external data sources that return JSON and need to convert that data into structured, type-safe PHP objects. It is particularly useful for those building or maintaining applications that frequently consume JSON from RESTful services, SDKs, or third-party integrations.
Developers choose JsonMapper over manual mapping or basic array access because it automates object hydration with type safety, reduces boilerplate code, and minimizes errors. Its extensible middleware architecture allows customization for edge cases without sacrificing simplicity, and it supports modern PHP features like typed properties alongside traditional doc blocks.
Map nested JSON structures to PHP classes
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Automatically enforces type validation using doc block annotations or PHP 7.4+ typed properties, reducing runtime errors and boilerplate code for JSON mapping.
Seamlessly converts between JSON naming conventions (e.g., snake_case) and PHP property names (e.g., camelCase), eliminating manual key adjustments.
Core designed with middleware allows custom logic for edge cases, such as complex nested mappings or data transformations, without modifying the library.
Includes debugging capabilities to trace mapping issues, which aids in development and troubleshooting without external tools.
Uses PHP reflection to inspect properties and types, which can slow down mapping compared to direct array access or manual assignment, especially in high-throughput scenarios.
Relies on doc block annotations or PHP 7.4+ typed properties, making it less suitable for legacy codebases or projects that avoid annotations for cleanliness.
Does not natively support PHP 8 attributes for metadata, requiring custom middleware implementation if attributes are preferred over doc blocks.