     }
     
     func unwrap(_ value: Primitive?) throws -> Int? {
-        guard let primitiveValue = value else {
+        guard let primitiveValue = value, !(primitiveValue is NSNull) else {
             return nil
         }
         

    func encode(_ value: UInt16) throws { try encoder.target.primitive = encoder.convert(value) }
    func encode(_ value: UInt32) throws { try encoder.target.primitive = encoder.convert(value) }
    func encode(_ value: Float) throws { try encoder.target.primitive = encoder.convert(value) }
    func encode(_ value: Double) throws { try encoder.target.primitive = encoder.convert(value) }
    func encode(_ value: String) throws { try encoder.target.primitive = encoder.convert(value) }
    func encode(_ value: UInt) throws { try encoder.target.primitive = encoder.convert(value) }
    func encode(_ value: UInt64) throws { try encoder.target.primitive = encoder.convert(value) }

    }
    
    func unwrap(_ value: Primitive?) throws -> Bool? {
        guard let primitiveValue = value, !(primitiveValue is NSNull) else {
            return nil
        }
        
