public function toJson($key = null, $options = 0)
    {
        if (is_string($key)) {
            return json_encode($this->get($key), $options);
        }
        $options = $key === null ? 0 : $key;
        return json_encode($this->elements, $options);
    }
public function toJson($key = null, $options = 0)
    {
        if (is_string($key)) {
            return json_encode($this->get($key), $options);
        }
        $options = $key === null ? 0 : $key;
        return json_encode($this->elements, $options);
    }
public function toJson ( $ key = null , $ options = 0 ) { if ( is_string ( $ key ) ) { return json_encode ( $ this -> get ( $ key ) , $ options ) ; } $ options = $ key === null ? 0 : $ key ; return json_encode ( $ this -> elements , $ options ) ; }
Return the value of a given key or all the values as JSON

@param  mixed  $key
@param  int    $options
@return string
Return the value of a given key or all the values as JSON