/** * Our specialized json encoder. Strings will be converted to UTF-8. Arrays will be recursively searched and * both keys and values made UTF-8. Objects will be converted with json_encode, and so objects that need a special * encoding should implement the jsonSerializable interface. See below * @param mixed $objValue * @return string */ public static function toJSON($objValue) { assert('is_array($objValue) || is_object($objValue)'); // json spec says only arrays or objects can be encoded $objValue = JavaScriptHelper::MakeJsonEncodable($objValue); $strRet = json_encode($objValue); if ($strRet === false) { throw new QCallerException('Json Encoding Error: ' . json_last_error_msg()); } return $strRet; }