PHPackages                             zahran/data-mapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. zahran/data-mapper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

zahran/data-mapper
==================

A data mapping tool that helps you rewrite JSON content or modify it.

1.2.2(5y ago)691[2 PRs](https://github.com/mozahran/data-mapper/pulls)MITPHPPHP &gt;=7.2.0

Since Mar 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mozahran/data-mapper)[ Packagist](https://packagist.org/packages/zahran/data-mapper)[ RSS](/packages/zahran-data-mapper/feed)WikiDiscussions main Synced 6d ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

[![Build Status](https://github.com/mozahran/data-mapper/actions/workflows/php.yml/badge.svg)](https://github.com/mozahran/data-mapper/actions/workflows/php.yml)

JSON Data Mapper
================

[](#json-data-mapper)

> Author: [Mohamed Zahran](https://www.linkedin.com/in/mo-zahran/)

Requirements
------------

[](#requirements)

- PHP 7.2 or higher.
- cakephp/utility 4.0 or higher.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Examples](#mappings-examples)
    1. [Mapping JSON Objects](#1-mapping-json-objects)
    2. [Mapping JSON Arrays](#2-mapping-json-arrays)
    3. [Applying Conditions](#3-applying-conditions)
    4. [Cast Values To Another Type](#4-cast-values-to-another-type)
    5. [Applying Mutators](#5-applying-mutators)
    6. [Additional Features](#6-additional-features)
- [Extending The Package](#extending-the-package)
    1. [Custom Cast Type](#custom-cast-type)
    2. [Add Custom Condition](#add-custom-condition)
    3. [Add Custom Mutator](#add-custom-mutator)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

Install using composer:

```
composer require zahran/data-mapper
```

Usage
-----

[](#usage)

After installing the package, make sure you get an instance of the `Container` and register the instances that the tool needs. Each instance have an alias/id so it can be easily overridden by custom implementations. The overriding part will be explained in detail later on.

```
