Open
Conversation
Allowing the wrong type definition does not cause the entire parent node JSONModel to be nil. "// 1) check if property is itself a JSONModel" has the same conditions.
Member
|
It looks like the changes to the For the functional change, could you please give me some detail/explanation as to why it's not right now, why it should be changed, what implications that might have, etc.? This seems more like an opinion issue rather than the current behaviour being wrong, but I might not be fully understanding yet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allowing the wrong type definition does not cause the entire parent node JSONModel to be nil. "// 1) check if property is itself a JSONModel" has the same conditions.
NSString* jsonData = @{@"person":{ @"name": @"joke", @"age": @18, @"desc": [NSNull null]}}; // from server response data
@interface MYJSONModel : JSONModel
@EnD
@implementation MYJSONModel
return YES;
}
@EnD
@interface PersonItem : MYJSONModel
@Property (nonatomic, copy) NSString* name;
@Property (nonatomic, assign) NSInteger age;
@Property (nonatomic, copy) NSString* desc;
@EnD
@interface PersonInfo : MYJSONModel
@Property (nonatomic, strong) PersonItem* person;
@EnD
NSError* error;
PersonInfo* p = [[PersonInfo alloc] ] initWithDictionary: jsonData error:&error];
NSString* jsonData = @{@"person":{ @"name": @"joke", @"age": @18, @"desc": [NSNull null] }};
server change desc from string to dictionary:
NSString* jsonData = @{@"person":{ @"name": @"joke", @"age": @18, @"desc": @{@"more":@"more detail"} }};
Result: p.person is nil and error is nil.
i want p.person is not nil & p.person.desc could be nil in this case.
when [property.isOptional || !validation] return error should be more careful in traverse properties.