PHPackages                             monsieurbon/json-serializer - 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. monsieurbon/json-serializer

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

monsieurbon/json-serializer
===========================

A lightweight PHP JSON serializer

v1.5.0(7y ago)046MITPHPPHP ~7.2

Since Nov 26Pushed 7y ago1 watchersCompare

[ Source](https://github.com/MonsieurBon/json-serializer)[ Packagist](https://packagist.org/packages/monsieurbon/json-serializer)[ RSS](/packages/monsieurbon-json-serializer/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (8)Used By (0)

JsonSerializer
==============

[](#jsonserializer)

[![Build Status](https://camo.githubusercontent.com/da750a002ea75f9a180b23e843f49573bde3247ec1a30cb0c4e511b324f6a373/68747470733a2f2f7472617669732d63692e6f72672f4d6f6e7369657572426f6e2f6a736f6e2d73657269616c697a65722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/MonsieurBon/json-serializer) [![codecov](https://camo.githubusercontent.com/997d2d82353fdcc48b6573b0e20bdd1149d08de88ea8ac39d7bbdc387a7c573c/68747470733a2f2f636f6465636f762e696f2f67682f4d6f6e7369657572426f6e2f6a736f6e2d73657269616c697a65722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/MonsieurBon/json-serializer) [![Sonarcloud Status](https://camo.githubusercontent.com/97e8b9c057b778b384b340742eb3657b4be0684259d7cd4f1d9bfa296e3c3ce3/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636f6d2e6c61706f74732e62726565642e6a756467653a6a756467652d72756c652d656e67696e65266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=MonsieurBon_json-serializer)

A lightweight PHP JSON serializer

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

[](#installation)

```
composer require monsieurbon/json-serializer
```

Usage
-----

[](#usage)

```
$serializer = new JsonSerializer();
$serializer->configure('path/to/some/config.yml');

$json = $serializer->serialize($myObject);
$myObject = $serializer->deserialize($json, MyClass::class);
$myObject = $serializer->deserialize($json, function ($dataArray) {
    return 'My\ClassName\From\DataArray';
});
```

### Configuration

[](#configuration)

You can supply a configuration file in yaml format:

```
NameSpace\Of\MyObject:
  arrayProperty: 'array'
  booleanProperty: 'boolean'
  dateProperty:
    type: 'date'
    dateFormat: 'Y-m-d\TH:i:s\Z'
  floatProperty: 'float'
  integerProperty: 'integer'
  stringProperty: 'string'
  nestedObject: 'NameSpace\Of\MyNestedObject'
  factoryObject:
    type: 'NameSpace\Of\FactoryObject'
    factoryMethod: 'fromData'
NameSpace\Of\MyNestedObject:
  dateProperty: 'date'
```

The type `date` supports an optional dateFormat property. It defaults to `d-m-Y H:i:s\Z`. For nested objects you can define a static factory method that will be called with the data to create the object.

If you want to specify the data that will be serialized for an object, implement the standard php \\JsonSerializable interface.

Dependencies
------------

[](#dependencies)

The following PHP extensions are required:

- ext-yaml
- ext-json

This package only handles the reflection part of (de)serializing and depends on the PHP json extension for the actual (de)serialization.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~19 days

Recently: every ~7 days

Total

7

Last Release

2610d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e3305ec1ec7944f1c7a127e6e7b00a447500e6b85d82a6b3f4bc3adabfddc772?d=identicon)[MonsieurBon](/maintainers/MonsieurBon)

---

Top Contributors

[![MonsieurBon](https://avatars.githubusercontent.com/u/437910?v=4)](https://github.com/MonsieurBon "MonsieurBon (15 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/monsieurbon-json-serializer/health.svg)

```
[![Health](https://phpackages.com/badges/monsieurbon-json-serializer/health.svg)](https://phpackages.com/packages/monsieurbon-json-serializer)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
