PHPackages                             2befound/json-resolver - 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. 2befound/json-resolver

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

2befound/json-resolver
======================

A simple tool to resolve objects / trees of objects when encoding / decoding json

1.0.0(8y ago)015MITPHP

Since Nov 24Pushed 6y agoCompare

[ Source](https://github.com/2beFound/json-resolver)[ Packagist](https://packagist.org/packages/2befound/json-resolver)[ RSS](/packages/2befound-json-resolver/feed)WikiDiscussions master Synced 6d ago

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

JsonResolver
============

[](#jsonresolver)

JsonResolver is a simple class that enables you to recursively encode / decode a tree of objects to json without having to deal with stdClasses.

This is being achieved by simply injecting the original class into the json as "json\_resolve\_class" property.

Installation
============

[](#installation)

JsonResolver can be installed via. composer:

```
{
    "require": {
        "gries/json-resolver": "dev-master"
    },
}

```

Usage
=====

[](#usage)

Every plain php object is supported the only requirement is that \\JsonSerializeable is implemented.

Current features:

- automatically decodes objects back to their previous classes.
- automatically decodes related objects back to their previous classes if they implement the \\JsonSerializeable interface.
- automatically decodes arrays / traversable related objects if their values implement the \\JsonSerializeable interface.
- has a fallback method for objects that have not been previously encoded with the JsonResolver

example usage
-------------

[](#example-usage)

```
