* @link http://www.php.net/manual/en/class.arrayobject.php */ class JSONArrayObject extends MultiDimArrayObject { /** * Construct an array object from a json string * * @param string $input a json string */ function __construct($input) { if (is_string($input)) { $input = (array)json_decode($input, true); } parent::__construct($input); } /** * magic method for use of object in string context * * @return string internal array converted to json */ function __toString() { return json_encode($this->getArrayCopy()); } }