diff --git a/Parse/Parse/Source/PFDecoder.m b/Parse/Parse/Source/PFDecoder.m index 33054d609..7eb99dec7 100644 --- a/Parse/Parse/Source/PFDecoder.m +++ b/Parse/Parse/Source/PFDecoder.m @@ -47,6 +47,28 @@ - (id)decodeDictionary:(NSDictionary *)dictionary { } NSString *type = dictionary[@"__type"]; + // Inject __type = @"Object" if missing but className/objectId present and on the presence of additional data fields so that bare pointer stubs continue to fall back to the legacy dictionary path. + if (!type && dictionary[@"className"] && dictionary[@"objectId"]) { + static NSSet *pointerKeys; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + pointerKeys = [NSSet setWithObjects:@"className", @"objectId", @"localId", nil]; + }); + BOOL hasAdditionalFields = NO; + for (NSString *key in dictionary) { + if (![pointerKeys containsObject:key]) { + hasAdditionalFields = YES; + break; + } + } + if (!hasAdditionalFields) { + return dictionary; + } + NSMutableDictionary *mutable = [dictionary mutableCopy]; + mutable[@"__type"] = @"Object"; + type = @"Object"; + dictionary = mutable; + } if (type) { if ([type isEqualToString:@"Date"]) { return [[PFDateFormatter sharedFormatter] dateFromString:dictionary[@"iso"]]; diff --git a/ParseLiveQuery/ParseLiveQuery/Internal/ClientPrivate.swift b/ParseLiveQuery/ParseLiveQuery/Internal/ClientPrivate.swift index 45eb2c54c..cd11e9ab9 100644 --- a/ParseLiveQuery/ParseLiveQuery/Internal/ClientPrivate.swift +++ b/ParseLiveQuery/ParseLiveQuery/Internal/ClientPrivate.swift @@ -18,7 +18,6 @@ private func parseObject(_ objectDictionary: [String:AnyObject]) th guard let _ = objectDictionary["objectId"] as? String else { throw LiveQueryErrors.InvalidJSONError(json: objectDictionary, expectedKey: "objectId") } - guard let object = PFDecoder.object().decode(objectDictionary) as? T else { throw LiveQueryErrors.InvalidJSONObject(json: objectDictionary, details: "cannot decode json into \(T.self)") }