Class for wrapping JSON encoding/decoding functionality.

Given that the json extension to PHP will be enabled by default in PHP 5.2.0+, Solar_Json allows users to get a jump on JSON encoding and decoding early if the native json_* functions are not present.

Solar_Json::encode and Solar_Json::decode functions are designed to pass the same unit tests bundled with the native PHP json ext.

Based largely on the Services_JSON package by Michal Migurski, Matt Knapp and Brett Stimmerman. See the original code at » http://mike.teczno.com/JSON/JSON.phps


This class is part of the Solar_Json package.


Configuration Keys

  • bypass_ext: Flag to instruct Solar_Json to bypass native json extension, if installed.

  • bypass_mb: Flag to instruct Solar_Json to bypass native mb_convert_encoding() function, if installed.

  • noerror: Flag to instruct Solar_Json to return null for values it cannot encode rather than throwing an exceptions (PHP-only encoding) or PHP warnings (native json_encode() function).


Public Properties

The Solar_Json class has no public properties; try the list of all properties.

Public Methods

These are all the public methods in the Solar_Json class.

You can also view the list of all public, protected, and private methods.




Default destructor; does nothing other than provide a safe fallback for calls to parent::__destruct().


Decodes the $encodedValue string which is encoded in the JSON format.


Convenience method for getting a dump the whole object, or one of its properties, or an external variable.


Encodes the mixed $valueToEncode into JSON format.


Looks up class-specific locale strings based on a key.