Skip to content

Commit 1a5c608

Browse files
Readme updates
1 parent fe205c2 commit 1a5c608

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,28 @@ Object mapper can map classes composed of the following types:
7070
- String
7171
- Array\<AnyObject\>
7272
- Dictionary\<String, AnyObject\>
73-
- Optionals of all the abovee
7473
- Object\<T: Mappable\>
7574
- Array\<T: Mappable\>
7675
- 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+
```
7792

7893
##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:
8095
```swift
8196
birthday <= (map["birthday"], DateTransform())
8297
```
@@ -92,20 +107,6 @@ public protocol TransformType {
92107
func transformToJSON(value: Object?) -> JSON?
93108
}
94109
```
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-
```
109110

110111
##To Do
111112
- Support for implicitly unwrapped optionals (ex. var user: User!)

0 commit comments

Comments
 (0)