     fileprivate func _writeContainerIntoFlock( handle: FileHandle,
                                                container: Container)throws->(){
         try autoreleasepool { () -> Void in
-            var data=container.serialize()
+            let jsonDictionary=container.toJSON()
+            var data = try JSONSerialization.data(withJSONObject: jsonDictionary)
             data = try data.compress(algorithm: .lz4)
             data = try self._cryptoHelper.encryptData(data)
             var cryptedSize:UInt64=UInt64(data.count)

//

import Foundation

enum FlockerError:Error{
    case unableToAccessToContainer(at:String,message:String)

                    var data=fileHandle.readData(ofLength: Int(footerSize))
                    data = try self._cryptoHelper.decryptData(data)
                    data = try data.decompress(algorithm: .lz4)
                    if let jsonString=String.init(data: data, encoding: String.Encoding.utf8){
                         container = Mapper<Container>().map(JSONString: jsonString)
                    }else{
                        throw FlockerError.unableToAccessToContainer(at: flockedFile, message: "Mapping has failed")
                    }

                }catch let e{
                    error=e
                }
