public function json($data, int $code = 200): ResponseInterface
    {
        return $this->writeJson($this->responseFactory->createResponse($code), $data, $code);
    }
public function json($data, int $code = 200): ResponseInterface
    {
        return $this->writeJson($this->responseFactory->createResponse($code), $data, $code);
    }
public function json ( $ data , int $ code = 200 ) : ResponseInterface { return $ this -> writeJson ( $ this -> responseFactory -> createResponse ( $ code ) , $ data , $ code ) ; }
Write json data into response.

@param mixed $data
@param int   $code

@return ResponseInterface
Write json data into response .