You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm deserializing a JSON document that has multiple properties that aren't found in the target object and since the server-side object structure is subject to change we use the validateValue() callback to filter out properties that aren't on the local object so that we don't get NSUnknownKeyExceptions while deserializing.
It looks like there's a logic error in EVReflection.swift that's keeping this check from being done. validateValue() exists on the target object and is set to throw an exception on invalid keys but setValue() gets called leading to an NSUnknownKeyException. The problem seems to be the check on line 989
public static func setObjectValue<T>(_ anyObject: T, key: String, theValue: Any?, typeInObject: String? = nil, valid: Bool, conversionOptions: ConversionOptions = .DefaultDeserialize, parents: [NSObject] = []) where T: NSObject {
...
(line 987) var setValue: AnyObject? = value as AnyObject?
let validateFunction = "validate" + key.prefix(1).uppercased() + key.dropFirst() + ":error:"
if (anyObject as AnyObject).responds(to: Selector(validateFunction)) {
try anyObject.validateValue(&setValue, forKey: key)
}
anyObject.setValue(setValue, forKey: key)
Which as I understand is checking if a custom key validator exists and if not call the base validator validateValue(). I think the check needs to be changed to
if !(anyObject as AnyObject).responds(to: Selector(validateFunction)) {
try anyObject.validateValue(&setValue, forKey: key)
}
I've been doing this in my local copy the last few times I updated the library and it seems to fix the problem without causing other side effects.
The text was updated successfully, but these errors were encountered:
I'm deserializing a JSON document that has multiple properties that aren't found in the target object and since the server-side object structure is subject to change we use the validateValue() callback to filter out properties that aren't on the local object so that we don't get NSUnknownKeyExceptions while deserializing.
It looks like there's a logic error in EVReflection.swift that's keeping this check from being done. validateValue() exists on the target object and is set to throw an exception on invalid keys but setValue() gets called leading to an NSUnknownKeyException. The problem seems to be the check on line 989
Which as I understand is checking if a custom key validator exists and if not call the base validator validateValue(). I think the check needs to be changed to
I've been doing this in my local copy the last few times I updated the library and it seems to fix the problem without causing other side effects.
The text was updated successfully, but these errors were encountered: