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
Copy file name to clipboardExpand all lines: README.md
+108-4Lines changed: 108 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ SHModelObject
3
3
4
4
`SHModelObject` is a utility model Base Class that uses objective-c runtime to assign the values to instance variables and properties of the model class from an `NSDictionary`, Which is a basic usecase when using webservices that return JSON response.
Let say you have a WebService that serves you back the following Response:
9
9
@@ -79,7 +79,110 @@ you can override `- (void)serializeValue:(id)value withKey:(id)key` method if yo
79
79
80
80
##Parsing .NET JSON Dates to NSDate or NSTimeInterval
81
81
82
-
you can use `kDateConversionOption` to convert the .NET JSON Date Strings to either `NSDate` or `NSTimeInterval` or keep it as `NSString` and parse yourself.
82
+
you can use `kDateConversionOption` to convert the .NET JSON Date Strings to either `NSDate` or `NSTimeInterval` or keep it as `NSString` and parse yourself and also you can define `kInputDateFormat` to specify your input date format (JSON format, .NET Simple or .NET with timezone)
83
+
84
+
85
+
##Parsing instance variables which are also a subclass of `SHModelObject`
86
+
87
+
you dont have to do anything :). `SHModelObject` automatically handles it. checkout the sample code.
88
+
89
+
for example, following JSON
90
+
91
+
```
92
+
93
+
{
94
+
"name" : "Shan Ul Haq",
95
+
"person_id" : 123,
96
+
"image" : {
97
+
"image_id" : 234,
98
+
"image_url" : http://image_url,
99
+
"orientation" : "portrait"
100
+
}
101
+
}
102
+
103
+
```
104
+
will be automatically parsed into following object:
###Parsing arrays of objects which are a subclass of `SHModelObject`
128
+
129
+
similar to parsing `SHModelObject` instance variables, arrays can be handled too. you need to specify the mapping which will define that the JSON array consist of which object type.
0 commit comments