Skip to content

Commit ddd8214

Browse files
committed
Merge branch 'master' of https://github.com/icanzilb/JSONModel
2 parents e922fca + 494a284 commit ddd8214

33 files changed

Lines changed: 198 additions & 93 deletions

‎AppledocSettings.plist‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<plist version="1.0">
44
<dict>
55
<key>--project-name</key>
6-
<string>JSONModel 0.9.2</string>
6+
<string>JSONModel 0.10.0</string>
77
<key>--print-settings</key>
88
<true/>
99
<key>--project-company</key>

‎Changelog.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
Change-log
22
==========
3+
4+
## Nota Bene!
5+
6+
Version 0.10 will be one of (if not) the last version for the "0" major version.
7+
8+
Currently I'm wrapping up the features to get into 1.0 and the list of breaking changes it will introduce.
9+
10+
---
11+
12+
**Version 0.10** @ 2013-11-10
13+
14+
- fixed handling of *null* values in JSON, which was **broken until now**, make sure to test after upgrading. Now *null* values for required properties will result in a failed init of the model class.
15+
16+
- a number of pull requests for *JSONHTTPClient*, slowly trying to polish it
17+
18+
- added propertyIsIgnored: method, for ignoring primitive properties
19+
20+
- fixes in globalKeyMapper import/export JSON, fixes for automatic snake_case convertions, added masking of BOOL as struct for custom convertors
21+
322
**Version 0.9.3** @ 2013-09-25
423

524
- Bug fixes up to issue #90

‎JSONModel.podspec‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
Pod::Spec.new do |s|
22
s.name = "JSONModel"
3-
s.version = "0.9.3"
3+
s.version = "0.10.0"
44
s.summary = "Magical Data Modelling Framework for JSON. Create rapidly powerful, atomic and smart data model classes."
55
s.homepage = "http://www.jsonmodel.com"
66

77
s.license = { :type => 'MIT', :file => 'LICENSE_jsonmodel.txt' }
88
s.author = { "Marin Todorov" => "touch-code-magazine@underplot.com" }
99

10-
s.source = { :git => "https://github.com/icanzilb/JSONModel.git", :tag => "0.9.3" }
10+
s.source = { :git => "https://github.com/icanzilb/JSONModel.git", :tag => "0.10.0" }
1111

1212
s.ios.deployment_target = '5.0'
1313
s.osx.deployment_target = '10.7'

‎JSONModel/JSONModel/JSONModel.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// JSONModel.h
33
//
4-
// @version 0.9.3
4+
// @version 0.10.0
55
// @author Marin Todorov, http://www.touch-code-magazine.com
66
//
77

@@ -101,7 +101,7 @@ lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
101101
-(instancetype)initWithDictionary:(NSDictionary*)dict error:(NSError**)err;
102102

103103
/**
104-
* All JSONModel classes should be able to export themselves as a dictioanry of
104+
* All JSONModel classes should be able to export themselves as a dictionary of
105105
* JSON compliant objects.
106106
*
107107
* For most classes the inherited from JSONModel default toDictionary implementation

‎JSONModel/JSONModel/JSONModel.m‎

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// JSONModel.m
33
//
4-
// @version 0.9.3
4+
// @version 0.10.0
55
// @author Marin Todorov, http://www.touch-code-magazine.com
66
//
77

@@ -20,6 +20,7 @@
2020

2121

2222
#import <objc/runtime.h>
23+
#import <objc/message.h>
2324

2425
#import "JSONModel.h"
2526
#import "JSONModelClassProperty.h"
@@ -175,14 +176,14 @@ -(id)initWithDictionary:(NSDictionary*)dict error:(NSError**)err
175176
NSString* transformedName = nil;
176177

177178
//loop over the required properties list
178-
for (NSString* requiredPropertyName in requiredProperties) {
179+
for (JSONModelClassProperty* property in [self __properties__]) {
179180

180181
//get the mapped key path
181-
transformedName = keyMapper.modelToJSONKeyBlock(requiredPropertyName);
182+
transformedName = keyMapper.modelToJSONKeyBlock(property.name);
182183

183184
//chek if exists and if so, add to incoming keys
184185
if ([dict valueForKeyPath:transformedName]) {
185-
[transformedIncomingKeys addObject: requiredPropertyName];
186+
[transformedIncomingKeys addObject: property.name];
186187
}
187188
}
188189

@@ -220,9 +221,16 @@ -(id)initWithDictionary:(NSDictionary*)dict error:(NSError**)err
220221
id jsonValue = [dict valueForKeyPath: jsonKeyPath];
221222

222223
//check for Optional properties
223-
if (isNull(jsonValue) && property.isOptional==YES) {
224+
if (isNull(jsonValue)) {
224225
//skip this property, continue with next property
225-
continue;
226+
if (property.isOptional==YES) continue;
227+
228+
//null value for required property
229+
NSString* msg = [NSString stringWithFormat:@"Value of required model key %@ is null", property.name];
230+
JSONModelError* dataErr = [JSONModelError errorInvalidDataWithMessage:msg];
231+
*err = [dataErr errorByPrependingKeyPathComponent:property.name];
232+
233+
return nil;
226234
}
227235

228236
Class jsonValueClass = [jsonValue class];
@@ -331,6 +339,9 @@ -(id)initWithDictionary:(NSDictionary*)dict error:(NSError**)err
331339
||
332340
//the property is mutable
333341
property.isMutable
342+
||
343+
//custom struct property
344+
property.structName
334345
) {
335346

336347
// searched around the web how to do this better
@@ -723,10 +734,8 @@ -(BOOL)__customSetValue:(id<NSObject>)value forProperty:(JSONModelClassProperty*
723734

724735
if (property.setterType==kCustom) {
725736
//call the custom setter
726-
#pragma clang diagnostic push
727-
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
728-
[self performSelector:property.customSetter withObject:value];
729-
#pragma clang diagnostic pop
737+
//https://github.com/steipete
738+
((void (*) (id, SEL, id))objc_msgSend)(self, property.customSetter, value);
730739
return YES;
731740
}
732741

@@ -756,9 +765,7 @@ -(BOOL)__customGetValue:(id<NSObject>*)value forProperty:(JSONModelClassProperty
756765
//call the custom getter
757766
#pragma clang diagnostic push
758767
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
759-
760768
*value = [self performSelector:property.customGetter withObject:nil];
761-
762769
#pragma clang diagnostic pop
763770
return YES;
764771
}

‎JSONModel/JSONModel/JSONModelArray.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// JSONModelArray.m
33
//
4-
// @version 0.9.3
4+
// @version 0.10.0
55
// @author Marin Todorov, http://www.touch-code-magazine.com
66
//
77

‎JSONModel/JSONModel/JSONModelClassProperty.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// JSONModelClassProperty.h
33
//
4-
// @version 0.9.3
4+
// @version 0.10.0
55
// @author Marin Todorov, http://www.touch-code-magazine.com
66
//
77

‎JSONModel/JSONModel/JSONModelClassProperty.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// JSONModelClassProperty.m
33
//
4-
// @version 0.9.3
4+
// @version 0.10.0
55
// @author Marin Todorov, http://www.touch-code-magazine.com
66
//
77

‎JSONModel/JSONModel/JSONModelError.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// JSONModelError.h
33
//
4-
// @version 0.9.3
4+
// @version 0.10.0
55
// @author Marin Todorov, http://www.touch-code-magazine.com
66
//
77

‎JSONModel/JSONModel/JSONModelError.m‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// JSONModelError.m
33
//
4-
// @version 0.9.3
4+
// @version 0.10.0
55
// @author Marin Todorov, http://www.touch-code-magazine.com
66
//
77

0 commit comments

Comments
 (0)