src/Plugin/Json.php
public function encode($data, $options = 0, $depth = 512)
    {
        $server   = $this->getServer();
        $response = $server->getResponse(false);
        $json     = json_encode($data, $options, $depth);
        if (false === $json) {
            throw new RuntimeException(
                json_last_error_msg(),
                json_last_error()
            );
        }
        $response->getBody()->write($json);
        $result = $response->withHeader(
            'Content-Type',
            'application/json;charset=utf-8'
        );

        return $result;
    }
public function encode($data, $options = 0, $depth = 512)
    {
        $server   = $this->getServer();
        $response = $server->getResponse(false);
        $json     = json_encode($data, $options, $depth);
        if (false === $json) {
            throw new RuntimeException(
                json_last_error_msg(),
                json_last_error()
            );
        }
        $response->getBody()->write($json);
        $result = $response->withHeader(
            'Content-Type',
            'application/json;charset=utf-8'
        );

        return $result;
    }
public function encode ( $ data , $ options = 0 , $ depth = 512 ) { $ server = $ this -> getServer ( ) ; $ response = $ server -> getResponse ( false ) ; $ json = json_encode ( $ data , $ options , $ depth ) ; if ( false === $ json ) { throw new RuntimeException ( json_last_error_msg ( ) , json_last_error ( ) ) ; } $ response -> getBody ( ) -> write ( $ json ) ; $ result = $ response -> withHeader ( 'Content-Type' , 'application/json;charset=utf-8' ) ; return $ result ; }
Encodes data and returns the response.

@param mixed $data    The data to encode
@param int   $options The bitmask of options
@param int   $depth   The maximum depth

@throws \RuntimeException If encoding fails

@return \Psr\Http\Message\ResponseInterface The response
Encodes data and returns the response .