     }
     
     convenience init(request: BRHTTPRequest, code: Int) {
-        self.init(request: request, statusCode: code, statusReason: BRHTTPResponse.reasonMap[code], headers: nil, body: nil)
+        self.init(
+            request: request, statusCode: code, statusReason: BRHTTPResponse.reasonMap[code], headers: nil, body: nil)
+    }
+    
+    convenience init(request: BRHTTPRequest, code: Int, json j: AnyObject) throws {
+        let jsonData = try NSJSONSerialization.dataWithJSONObject(j, options: [])
+        let bodyBuffer = UnsafeBufferPointer<UInt8>(start: UnsafePointer(jsonData.bytes), count: jsonData.length)
+        self.init(
+            request: request, statusCode: code, statusReason: BRHTTPResponse.reasonMap[code],
+            headers: ["Content-Type": ["application/json"]], body: Array(bodyBuffer))
     }
     
     func send() throws {

            return nil
        }
        _body = buf
        return NSData(bytesNoCopy: UnsafeMutablePointer(_body!), length: contentLength)
    }
    
    func rangeHeader() throws -> (Int, Int)? {

    
    public func body() -> NSData? {
        if _bodyRead && _body != nil {
            return NSData(bytesNoCopy: UnsafeMutablePointer(_body!), length: contentLength, freeWhenDone: false)
        }
        if _bodyRead {
            return nil
