Created
June 3, 2019 11:35
-
-
Save balrajOla/7524cc27da076b7760b25b486bbdac9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// json is a variable holding a JSON Data value | |
let myStruct = try JSONDecoder().decode(Content.self, from: json) // decoding our data | |
myStruct.body.forEach { (value: BodyContent) in | |
switch value { | |
case .number(let number): | |
print("Data for type: number is Data: \(number)") | |
case .text(let string): | |
print("Data for type: string is Data: \(string)") | |
case .unsupported: | |
print("Type not supported") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment