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

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

arturdoruch/json
================

JSON component

1.0.0(5y ago)027MITPHPPHP &gt;=7.0

Since Jul 2Pushed 5y ago1 watchersCompare

[ Source](https://github.com/arturdoruch/json)[ Packagist](https://packagist.org/packages/arturdoruch/json)[ RSS](/packages/arturdoruch-json/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (2)Used By (0)

Json
====

[](#json)

- Wraps JSON decoding and encoding actions into class. Handles decoding error.
- Provides JSON syntax highlighting.

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

[](#installation)

Install by running composer command `composer require arturdoruch/json`

Usage
-----

[](#usage)

### Decode JSON

[](#decode-json)

```
use ArturDoruch\Json\Json;
use ArturDoruch\Json\UnexpectedJsonException;

$jsonString = '';
// Decode JSON to array or stdClass object.
// If JSON is invalid `ArturDoruch\Json\UnexpectedJsonException` is thrown.
$json = new Json($jsonString);

// Get decoded JSON.
$json->getDecoded();

// Get encoded JSON with specified options like JSON_PRETTY_PRINT.
$json->getEncoded();

// Catch decoding exception
try {
    $json = new Json($jsonString);
} catch (UnexpectedJsonException $exception) {
    // Get decoded invalid JSON.
    $exception->getJson();
    // Get error code.
    $exception->getCode();
}
```

### Highlight JSON syntax

[](#highlight-json-syntax)

```
use ArturDoruch\Json\JsonUtils;

// JSON string.
$json = '{"string": "foo bar \"baz\"", "integer": 128, "float": -1.5678, "boolean": true, "null": null}';
$classPrefix = 'json';
$highlighted = JsonUtils::highlightSyntax($json, $classPrefix);
```

Define the following CSS styles to styling JSON code:

- span.{classPrefix}-key {}
- span.{classPrefix}-string {}
- span.{classPrefix}-integer {}
- span.{classPrefix}-float {}
- span.{classPrefix}-boolean {}
- span.{classPrefix}-null {}

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2143d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5af341236bd5f7de04934e7b63ab71d774df81f5409e7fafd19ede18c0cd6c2a?d=identicon)[arturdoruch](/maintainers/arturdoruch)

---

Top Contributors

[![arturdoruch](https://avatars.githubusercontent.com/u/6686928?v=4)](https://github.com/arturdoruch "arturdoruch (3 commits)")

---

Tags

jsonhighlight syntaxhandle decoding error

### Embed Badge

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

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

###  Alternatives

[justinrainbow/json-schema

A library to validate a json schema.

3.6k316.9M612](/packages/justinrainbow-json-schema)[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30422.2M45](/packages/colinodell-json5)[clue/ndjson-react

Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.

15267.7M16](/packages/clue-ndjson-react)

PHPackages © 2026

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