public function encode()
    {
        if (!empty($this->attributes)) {
            foreach ($this->attributes as $name => $params) {
                if (is_numeric($name)) {
                    $name = $params;
                }
                /** @var ActiveRecord $owner */
                $owner = $this->owner;
                if ($owner->hasAttribute($name)) {
                    $owner->setAttribute($name, Json::encode($owner->getAttribute($name)));
                }
            }
        }
    }