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

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

hgg/json
========

Encode, decode, validate, handle errors (exceptions) and pretty print JSON

v0.1.0(11y ago)194MITPHPPHP &gt;=5.3.3

Since Jul 23Pushed 11y ago1 watchersCompare

[ Source](https://github.com/hglattergotz/json)[ Packagist](https://packagist.org/packages/hgg/json)[ Docs](http://github.com/hglattergotz/json)[ RSS](/packages/hgg-json/feed)WikiDiscussions master Synced 3d ago

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

Json
====

[](#json)

[![Build Status](https://camo.githubusercontent.com/de59900d6ff8d7830cbc48a84147cfd3eca8808143de77454aa42e878f63d121/68747470733a2f2f7472617669732d63692e6f72672f68676c6174746572676f747a2f6a736f6e2e706e67)](https://travis-ci.org/hglattergotz/json)

Json is a collection of static methods to simplify working with JSON in PHP.

Features
--------

[](#features)

- ***encode*** to JSON string with error handling
- ***decode*** from a string or file path containing valid JSON with error handling
- ***validate*** a JSON document against a JSON Schema
- ***pretty print*** a JSON string

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

[](#installation)

- Via [Composer](http://getcomposer.org), package [hgg/json](https://packagist.org/packages/hgg/json)

**NOTE:**

The json-schema library version used here is currently a fork so you need to add the following to your composer.json file.

```
    "repositories": [
        {
            "type": "vcs",
            "url": "http://github.com/hglattergotz/json-schema"
        }
    ],
```

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

[](#dependencies)

- [JsonPretty](https://github.com/camspiers/json-pretty) A Json pretty printer by Cam Spiers
- [JsonSchema](https://github.com/justinrainbow/json-schema) A Json Schema validation library by Justin Rainbow

Usage
-----

[](#usage)

### Encode

[](#encode)

```
