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
The default implementation of `func toJSON()` inspects the properties of your type using reflection (see `Company`.) If you need a different mapping, you can provide your own implementation (see `User`.)
81
81
82
82
Instantiate your struct, then use the `func toJSON()` method to obtain a equivalent form suitable for use with `NSJSONSerialization`:
83
-
```
83
+
```swift
84
84
let dict =try user.toJSON()
85
85
print("dict: \(dict)")
86
86
```
87
87
88
88
Result:
89
-
```
89
+
```swift
90
90
[full_name: John Appleseed, id:24, email: john@appleseed.com, company: {
91
91
address ="1 Infinite Loop, Cupertino, CA";
92
92
name = Apple;
@@ -109,7 +109,7 @@ Result:
109
109
##Using JSONDecodable
110
110
111
111
Simply add conformance to `JSONDecodable` (or to `JSONCodable`):
0 commit comments