PHP Classes

File: doc/

Recommend this page to a friend!
  Classes of Julian Finkler   JSON Object Mapper   doc/   Download  
File: doc/
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: JSON Object Mapper
Create objects of classes mapped from JSON strings
Author: By
Last change:
Date: 4 years ago
Size: 1,299 bytes


Class file image Download

JSON Object Mapper Documentation


  1. Simple Mapping
  2. Mapping with Typehints
  3. Mapping Alternative Property Names
  4. Using Transformers
  5. Convert an Mapped Object to JSON
  6. Multiple Annotations

Basic usage

JOM is totally easy to use. Simply put the annotation @MintWare\JOM\JsonField() to your class properties.



    "first_name": "Pete",
    "surname": "Peterson",
    "age": 28,
    "address": {
        "street": "Mainstreet 22a",
        "zip_code": "A-12345",
        "town": "Best Town"

Data Class:


use MintWare\JOM\JsonField;

class Person
    / @JsonField(name="first_name", type="string") */
    public $firstName;
    / @JsonField(name="surname", type="string") */
    public $lastname;
    / @JsonField() */
    public $age;
    / @JsonField(type="Some\Other\DataClass\Address") */
    public $address;

Map the JSON:


use  MintWare\JOM\ObjectMapper;

$mapper = new ObjectMapper();
$person = $mapper->mapJson(file_get_contents('person.json'), Person::class);