src/db/ActiveRecord.php
public function toJson(array $fields = [], array $expand = [], $recursive = true)
    {
        return Json::encode($this->toArray($fields, $expand, $recursive));
    }
public function toJson(array $fields = [], array $expand = [], $recursive = true)
    {
        return Json::encode($this->toArray($fields, $expand, $recursive));
    }
public function toJson ( array $ fields = [ ] , array $ expand = [ ] , $ recursive = true ) { return Json :: encode ( $ this -> toArray ( $ fields , $ expand , $ recursive ) ) ; }
Converts the model into an json.

This method will first identify which fields to be included in the resulting array by calling [[resolveFields()]].
If the model implements the [[Linkable]] interface, the resulting json will also have a `_link` element
which refers to a list of links as specified by the interface.

@param array $fields the fields being requested.
If empty or if it contains '*', all fields as specified by [[fields()]] will be returned.
Fields can be nested, separated with dots (.). e.g.: item.field.sub-field
`$recursive` must be true for nested fields to be extracted. If `$recursive` is false, only the root fields will be extracted.
@param array $expand the additional fields being requested for exporting. Only fields declared in [[extraFields()]]
will be considered.
Expand can also be nested, separated with dots (.). e.g.: item.expand1.expand2
`$recursive` must be true for nested expands to be extracted. If `$recursive` is false, only the root expands will be extracted.
@param bool $recursive whether to recursively return array representation of embedded objects.
@return string the json representation of the object
Converts the model into an json .