/** * Encodes a value to JSON * * This is a proxy method to json_encode() with proper exception handling * * @param mixed $value * @param int $options bitmask * @return string JSON encoded * @throws JSend_Exception */ public static function encode($value, $options = NULL) { if ($options === NULL) { $options = JSend::DEFAULT_OPTIONS; } // Encode the value to JSON and check for errors $result = json_encode($value, $options); return JSend::check_json_errors($result); }