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

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

stratadox/json
==============

v0.1(7y ago)013MITPHPPHP &gt;=7.2

Since Aug 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Stratadox/Json)[ Packagist](https://packagist.org/packages/stratadox/json)[ RSS](/packages/stratadox-json/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Json
====

[](#json)

[![Build Status](https://camo.githubusercontent.com/9f15bc6b7be9c6691bb7c6b8eca6a3bcb73d5f6c5bf9459d6c3504a9592814c4/68747470733a2f2f7472617669732d63692e6f72672f537472617461646f782f4a736f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Stratadox/Json)[![Coverage Status](https://camo.githubusercontent.com/fd2db1e5de15ccf398a54a56b547c72559284097281342d074a8d26603d7c8d5/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f537472617461646f782f4a736f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Stratadox/Json?branch=master)[![Infection Minimum](https://camo.githubusercontent.com/75f976ff51890b48c4275d393fefd76fc81f42c68faff5397fa43baf73d79913/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d696e4d73692d39302d627269676874677265656e2e737667)](https://travis-ci.org/Stratadox/Json)[![PhpStan Level](https://camo.githubusercontent.com/e58915c82e085736fd9da556ddfcae809f3d34c62575773ffeae09481619c66a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068707374616e2d372d627269676874677265656e2e737667)](https://travis-ci.org/Stratadox/Json)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2bb71f4bde5570b1676e984dc9f872ccd11e036dcbcff0972b4ee921aa57eb20/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f537472617461646f782f4a736f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Stratadox/Json/?branch=master)[![Maintainability](https://camo.githubusercontent.com/2cf80a4db787639d0854dd995e9c92d7e281ec5222cd06bcf0a4d8eb1d07eead/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f32393031363964373633373464616433323964382f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/Stratadox/Json/maintainability)[![Latest Stable Version](https://camo.githubusercontent.com/1e53836f0aa22c8bb75d44c7c7acb545de01b41d22ddeeb993b70223755090f6/68747470733a2f2f706f7365722e707567782e6f72672f737472617461646f782f6a736f6e2f762f737461626c65)](https://packagist.org/packages/stratadox/json)[![License](https://camo.githubusercontent.com/7dc37c77ad3702dd7c798bc7d9a0c0ac5437dd7c1b8f166ebb33b681bb12531d/68747470733a2f2f706f7365722e707567782e6f72672f737472617461646f782f6a736f6e2f6c6963656e7365)](https://packagist.org/packages/stratadox/json)

Json handling library for easily reading from and writing to json strings.

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

[](#installation)

Install with `composer require stratadox/json`

What is this?
-------------

[](#what-is-this)

This library provides a simple object-oriented way of dealing with json strings in php.

The basic idea is to create a `Json` (php) object from either a json string or "raw" data, which represents the json data in the php world. Through this object, the contents of the json data can be retrieved. The interface also provides a mechanism for altering the json structure, either by modifying the current instance or by returning a modified copy.

To produce a json-encoded text representation of the contents, simply casting the Json instance to string is enough.

How to use this?
----------------

[](#how-to-use-this)

The package provides two approaches to handling json structures: an immutable and a mutable way. They both implement the same interface and differ only in the way they implement the `write` method.

### Immutable Json

[](#immutable-json)

Create an immutable json structure by converting a json-encoded string:

```
