Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save balrajOla/7524cc27da076b7760b25b486bbdac9a to your computer and use it in GitHub Desktop.
Save balrajOla/7524cc27da076b7760b25b486bbdac9a to your computer and use it in GitHub Desktop.
// 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