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
+17-16Lines changed: 17 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,13 +70,28 @@ Object mapper can map classes composed of the following types:
70
70
- String
71
71
- Array\<AnyObject\>
72
72
- Dictionary\<String, AnyObject\>
73
-
- Optionals of all the abovee
74
73
- Object\<T: Mappable\>
75
74
- Array\<T: Mappable\>
76
75
- Dictionary\<String, T: Mappable\>
76
+
- Optionals of all the above
77
+
78
+
##Easy Mapping of Nested Objects
79
+
ObjectMapper supports dot notation within keys for easy mapping of nested objects. Given the following JSON String:
80
+
```
81
+
"distance" : {
82
+
"text" : "102 ft",
83
+
"value" : 31
84
+
}
85
+
```
86
+
You can access the nested objects as follows:
87
+
```
88
+
func mapping(map: Map){
89
+
distance <= map["distance.value"]
90
+
}
91
+
```
77
92
78
93
##Custom Transfoms
79
-
ObjectMapper also supports custom Transforms that convert values during the mapping process. To use a transform, simply create a tuple with the mapper["field_name"] and the transform of choice on the right side of the '<=' operator:
94
+
ObjectMapper also supports custom Transforms that convert values during the mapping process. To use a transform, simply create a tuple with ```map["field_name"]``` and the transform of choice on the right side of the ```<=``` operator:
80
95
```swift
81
96
birthday <= (map["birthday"], DateTransform())
82
97
```
@@ -92,20 +107,6 @@ public protocol TransformType {
92
107
functransformToJSON(value: Object?) -> JSON?
93
108
}
94
109
```
95
-
##Easy Mapping of Nested Objects
96
-
ObjectMapper supports dot notation within keys for easy mapping of nested objects. Given the following JSON String:
97
-
```
98
-
"distance" : {
99
-
"text" : "102 ft",
100
-
"value" : 31
101
-
}
102
-
```
103
-
You can access the nested objects as follows:
104
-
```
105
-
func mapping(map: Map){
106
-
distance <= map["distance.value"]
107
-
}
108
-
```
109
110
110
111
##To Do
111
112
- Support for implicitly unwrapped optionals (ex. var user: User!)
0 commit comments