PHPackages                             lendable/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. lendable/json-serializer

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

lendable/json-serializer
========================

JSON serializer/deserializer with an OOP interface

1.1.0(3mo ago)2121.2k↓11%[1 issues](https://github.com/Lendable/json-serializer/issues)[3 PRs](https://github.com/Lendable/json-serializer/pulls)MITPHPPHP &gt;=8.3,&lt;9CI passing

Since Nov 27Pushed 3w ago27 watchersCompare

[ Source](https://github.com/Lendable/json-serializer)[ Packagist](https://packagist.org/packages/lendable/json-serializer)[ RSS](/packages/lendable-json-serializer/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (9)Dependencies (18)Versions (21)Used By (0)

Lendable JSON Serializer
========================

[](#lendable-json-serializer)

[![Latest Stable Version](https://camo.githubusercontent.com/d96dd8b7aa034b24dfef6583ff27b64b7c6c71991aa6dc98076fad90444354e1/68747470733a2f2f706f7365722e707567782e6f72672f6c656e6461626c652f6a736f6e2d73657269616c697a65722f762f737461626c65)](https://packagist.org/packages/lendable/json-serializer)[![License](https://camo.githubusercontent.com/f851ed133ff715d47f718508b422d7dfac2b5cbeb8eafcb8d1600905a7a72347/68747470733a2f2f706f7365722e707567782e6f72672f6c656e6461626c652f6a736f6e2d73657269616c697a65722f6c6963656e7365)](https://packagist.org/packages/lendable/json-serializer)

Provides an opinionated object oriented interface for handling JSON serialization and deserialization in PHP.

Features
--------

[](#features)

- Throws exceptions on serialization and deserialization failure.
- Sane default serialization flags.

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

[](#installation)

```
composer require lendable/json-serializer
```

Why? Opinionated?
-----------------

[](#why-opinionated)

This library aids to simplify our most common usage patterns of JSON at Lendable by providing a strict and limited API, and not a generic solution.

### Type safety

[](#type-safety)

We follow the pattern of converting object graph(s) to data array(s) and then to JSON, this library fits into the `data array(s)  json` part of that flow. Due to this, it is restrictive in what can be serialized and deserialized as for our use case, these are error conditions. Data is deserialized always as a numeric (array root element) or an associative array (object root element). Therefore, this library may *not* fit your use case.

### Error handling

[](#error-handling)

The default `json_encode()` and `json_decode()` global functions from `ext-json` are still used, but delegated to in a safe manner. The potential error reporting from these functions can be:

- A `false` return value - except `json_decode('false')` also returns false, and isn't an error.
- Retrieved as code or message via `json_last_error()` or `json_last_error_msg()` - requires being checked every time.
- An exception via the `JSON_THROW_ON_ERROR` option in PHP 7.3 - requires opt-in to the functionality.

This library will always throw exceptions on serialization and deserialization failures, simplifying calling logic.

API
---

[](#api)

### Serialization `Serializer::serialize(array $data): string`

[](#serialization-serializerserializearray-data-string)

Serializes a data array into a JSON string.

Throws `SerializationFailed` on failure to serialize.

### Deserialization `Serializer::deserialize(string $json): array`

[](#deserialization-serializerdeserializestring-json-array)

Deserializes a JSON string into an `array`.

Throws `DeserializationFailed` on failure to deserialize. Throws `InvalidDeserializedData` if the data type of the resulting deserialized data is not an `array`.

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance79

Regular maintenance activity

Popularity34

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 60.5% 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 ~337 days

Recently: every ~307 days

Total

9

Last Release

97d ago

Major Versions

0.1.1 → 1.0.02019-03-01

PHP version history (8 changes)0.1.0PHP &gt;=7.1

1.0.0PHP &gt;=7.2

1.0.1PHP &gt;=7.4.0,&lt;8.2.0

1.0.2PHP &gt;=8.0,&lt;8.2

1.0.3PHP &gt;=8.0,&lt;8.3

1.0.4PHP &gt;=8.1,&lt;9

1.0.5PHP &gt;=8.2,&lt;9

1.1.0PHP &gt;=8.3,&lt;9

### Community

Maintainers

![](https://www.gravatar.com/avatar/893f1dc6753940f80d1fe2e9a90db68961bb7f16eab85d6a868e7aecccf8de13?d=identicon)[ben-challis](/maintainers/ben-challis)

---

Top Contributors

[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (398 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (196 commits)")[![ben-challis](https://avatars.githubusercontent.com/u/8275163?v=4)](https://github.com/ben-challis "ben-challis (32 commits)")[![marmichalski](https://avatars.githubusercontent.com/u/57528542?v=4)](https://github.com/marmichalski "marmichalski (16 commits)")[![kunicmarko20](https://avatars.githubusercontent.com/u/13528674?v=4)](https://github.com/kunicmarko20 "kunicmarko20 (7 commits)")[![martin-georgiev](https://avatars.githubusercontent.com/u/4849482?v=4)](https://github.com/martin-georgiev "martin-georgiev (6 commits)")[![velkovb](https://avatars.githubusercontent.com/u/10958657?v=4)](https://github.com/velkovb "velkovb (1 commits)")[![lendabot[bot]](https://avatars.githubusercontent.com/u/10513749?v=4)](https://github.com/lendabot[bot] "lendabot[bot] (1 commits)")[![AlexisColes](https://avatars.githubusercontent.com/u/8488871?v=4)](https://github.com/AlexisColes "AlexisColes (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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