I have JSON data which I am attempting to grab only the words including age. I plan on then grabbing all ages over 21. I've gotten as far as separating each word in the string as a separate string, but I can't see find a way to traverse each age.
let JSON = """
{"data":"key=IAfpK, age=58, key=WNVdi, age=4, key=jp9zt, age=47, key=0Sr4C, age=68, key=CGEqo, age=76"}
"""
struct DataObject: Decodable {
let data: String
}
func grabAges() {
let jsonData = JSON.data(using: .utf8)!
let dataObject: DataObject = try! JSONDecoder().decode(DataObject.self, from: jsonData)
var arr = dataObject.data.components(separatedBy: ",")
//print(dataObject.data)
}