         
         let attributeClassName = attributeDescription!.attributeValueClassName
         
-        // strings and numbers are standard json data types
-        if attributeClassName == "NSString" || attributeClassName == "NSNumber" {
-            
-            return attributeValue
-        }
-        
-        // date
-        if attributeClassName == "NSDate" {
-            
-            
+        switch attributeClassName {
+            
+            // strings and numbers are standard json data types
+            case "NSString", "NSNumber":
+                return attributeValue
+            
+            case "NSDate":
+                let date = attributeValue as NSDate
+                return date.ISO8601String()
+            
+            case "NSData":
+                let data = attributeValue as NSData
+                return data.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
         }
         
         // transformable value type
-        if attributeType == NSAttributeType.TransformableAttributeType {
+        if attributeDescription?.attributeType == NSAttributeType.TransformableAttributeType {
             
             // get transformer
             let valueTransformerName = attributeDescription?.valueTransformerName

            
            // custom transformer
            let transformer = NSValueTransformer(forName: valueTransformerName!)
            
            
        }
        
        return 0
    }
    
    func attributeValueForJSONCompatibleValue(JSONCompatibleValue: AnyObject, forAttribute attributeName: String) -> AnyObject? {

            // custom transformer
            let transformer = NSValueTransformer(forName: valueTransformerName!)
            
            // must convert to NSData
            let data = transformer.transformedValue(convertedValue) as? NSData
            
            return (data != nil)
            
        }
        
        return false
