Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save balrajOla/ce0e90c712028063944b2eb15d67bd4b to your computer and use it in GitHub Desktop.
Save balrajOla/ce0e90c712028063944b2eb15d67bd4b to your computer and use it in GitHub Desktop.
let myStruct = try JSONDecoder().decode(Content.self, from: json) // decoding our data
myStruct.body.forEach { bodyContent in
let value: String? = bodyContent.content?.getContent()
let intValue: Int? = bodyContent.content?.getContent()
let finalValue = value ?? intValue.map(String.init) ?? "NA"
print("Data for type: \(bodyContent.type) is Data: \(finalValue)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment