         public func encodeBody(parameters: [String : AnyObject]) -> NSData? {
             switch self {
             case .Percent:
-                return parameters.percentEncodedQueryString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
+                return parameters.percentEncodedQueryString?.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
             case .JSON:
-                do {
-                    return try NSJSONSerialization.dataWithJSONObject(parameters, options: NSJSONWritingOptions())
-                } catch _ {
-                    return nil
-                }
+                return try? NSJSONSerialization.dataWithJSONObject(parameters, options: NSJSONWritingOptions())
             }
         }
     }

         - returns: A NSURL value with query string parameters encoded.
        */
        public func encodeURL(url: NSURL, parameters: [String : AnyObject]) -> NSURL? {
            if let components = NSURLComponents(URL: url, resolvingAgainstBaseURL: false) {
                components.appendPercentEncodedQuery(parameters.percentEncodedQueryString)
                return components.URL
            }
            
            return nil
        }
        
        /**

// MARK: - Query String

extension Dictionary {
    /// Return an encoded query string using the elements in the dictionary.
    var percentEncodedQueryString: String? {
        let components = NSURLComponents(string: "")
        components?.queryItems = queryItems
        return components?.URL?.query
    }
    
    var queryItems: [NSURLQueryItem] {
        var items = [NSURLQueryItem]()
        
        for (name, value) in self {
            let item = NSURLQueryItem(name: "\(name)", value: "\(value)")
            items.append(item)
        }
        
        return items
    }
}

// MARK: - Percent Encoded Query

extension NSURLComponents {
    /// Append an array of query items to the existing `queryItems` property value.
    func appendQueryItems(newItems: [NSURLQueryItem]) {
        if let existingQueryItems = queryItems {
            queryItems = existingQueryItems + newItems
        } else {
            queryItems = newItems
        }
    }
}
