Create JSON response

Class Vegas\Http\Response\Json provides a simply JSON response builder, that might be useful to standardize responses returned by your application's controllers.

Example use:

    //...

    /**
     * Success response
     */
    public function createAction()
    {
        $response = new Json();
        $response->success()
            ->setData(array('test' => 1))
            ->setMessage('Test message');

        return $this->jsonResponse($response);
    }


    /**
    * Errors response
    */
    public function createAction()
    {
        $response = new Json();
        $response->fail()
            ->setData(array())
            ->setMessage('Errors...');

        return $this->jsonResponse($response);
    }

    //...

Success response will be in the following format:

{
    "success" : true,
    "data": {
        "test" : 1
    },
    "message" : "Test message"
}

Error response will be in the following format:

{
    "success" : false,
    "data": {},
    "message" : "Errors..."
}