Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 032adfa

Browse filesBrowse files
committed
1 parent 200e9bc commit 032adfa
Copy full SHA for 032adfa

File tree

Expand file treeCollapse file tree

3 files changed

+24
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+24
-3
lines changed
Open diff view settings
Collapse file

‎JSONModel/JSONModel/JSONModel.m‎

Copy file name to clipboardExpand all lines: JSONModel/JSONModel/JSONModel.m
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ -(id)initWithDictionary:(NSDictionary*)dict error:(NSError**)err
178178
transformedName = keyMapper.modelToJSONKeyBlock(property.name);
179179

180180
//chek if exists and if so, add to incoming keys
181-
if ([dict valueForKeyPath:transformedName]) {
181+
if (dict[transformedName]) {
182182
[transformedIncomingKeys addObject: property.name];
183183
}
184184
}
@@ -214,7 +214,7 @@ -(id)initWithDictionary:(NSDictionary*)dict error:(NSError**)err
214214
//JMLog(@"keyPath: %@", jsonKeyPath);
215215

216216
//general check for data type compliance
217-
id jsonValue = [dict valueForKeyPath: jsonKeyPath];
217+
id jsonValue = dict[jsonKeyPath];
218218

219219
//check for Optional properties
220220
if (isNull(jsonValue)) {
Collapse file

‎JSONModelDemoTests/UnitTests/KeyMappingTests.m‎

Copy file name to clipboardExpand all lines: JSONModelDemoTests/UnitTests/KeyMappingTests.m
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ +(JSONKeyMapper*)keyMapper
3232

3333
@end
3434

35+
#pragma mark - at-name property
36+
@interface AtNameModel : JSONModel
37+
@property (assign) int type;
38+
@end
39+
40+
@implementation AtNameModel
41+
+(JSONKeyMapper*)keyMapper
42+
{
43+
return [[JSONKeyMapper alloc] initWithDictionary:@{
44+
@"@type": @"type"
45+
}];
46+
}
47+
@end
48+
3549
#pragma mark - global key mapper test model
3650
@interface GlobalModel: JSONModel
3751
@property (strong, nonatomic) NSString* name;
@@ -185,4 +199,11 @@ -(void)testGlobalKeyMapperImportAndExport
185199
STAssertNil(global3, @"model supposed to be nil");
186200
}
187201

202+
//https://github.com/icanzilb/JSONModel/issues/132
203+
-(void)testAtNameProperty
204+
{
205+
AtNameModel* at = [[AtNameModel alloc] initWithString:@"{\"@type\":157}" error:nil];
206+
STAssertNotNil(at, @"model instance is nil");
207+
}
208+
188209
@end
Collapse file

‎JSONModelDemo_iOS/MasterViewController.m‎

Copy file name to clipboardExpand all lines: JSONModelDemo_iOS/MasterViewController.m
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ -(void)viewDidAppear:(BOOL)animated
138138
NSLog(@"%@ attr: %@", name, propertyAttributes);
139139
}
140140
141-
/*
141+
142142
NSString* json = @"{}";
143143
TopModel* mm = [[TopModel alloc] initWithString:json error:nil];
144144
NSLog(@"TopModel: %@", mm);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.