behaviors/JsonAttributeBehavior.php
public function jsonDecodeAttribute($name, $assoc = true, $depth = 512)
    {
        $string = json_decode($this->owner->$name, $assoc, $depth);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new CException(sprintf('Failed to decode JSON attribute "%s".', $name));
        }
        return $string;
    }
public function jsonDecodeAttribute($name, $assoc = true, $depth = 512)
    {
        $string = json_decode($this->owner->$name, $assoc, $depth);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new CException(sprintf('Failed to decode JSON attribute "%s".', $name));
        }
        return $string;
    }
JSON decodes the given attribute on the owner of this behavior.
@param string $name name of the attribute.
@param bool $assoc whether the result should be an associated array (default to true).
@param int $depth recursion depth.
@return string the decoded value.
@throws CException if the value cannot be decoded.