                 ]))
         }
     }
+
+
+    
     /// access json data object
     public var data:AnyObject? {
         return self.isError ? nil : self._value

extension JSON : Printable {
    /// stringifies self.
    /// if pretty:true it pretty prints
    public func toString(pretty:Bool=false)->String {
        switch _value {
        case is NSError: return "\(_value)"


    func post(data: AnyObject? = nil, url: String?=nil, headers: [String:String]?=nil, completionHandler: CompletionHandler? = nil, errorHandler: ErrorHandler? = nil) { //contentType, postData
        var fullURL = self.getFullURL(url)
        println("FullURL=\(fullURL)")
        if let request = self.generateURLRequest(fullURL, method: HTTPMethod.POST) {
//            self.setHeaders(request, headers)
//            if let concreteData: AnyObject = data {
//                if let type = self.detectDataType(concreteData) {
//                    self.setContentType(request, type)
//                }
                if let json = data! as? JSON {

                    let text = json.toString(pretty: true) as String
                    println("BODY=\(text)")
                    let data = text.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! as NSData
                    request.HTTPBody = data
                    
                    request.setValue("application/json",  forHTTPHeaderField:"Content-Type")
                }
//                else {
//                    request.HTTPBody = concreteData.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
//                }

//            }          
            var httpLayer = HTTPLayer(completionHandler, errorHandler)
            httpLayer.delegate = self
            httpLayer.request(request)
