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
let url = Bundle.main.url(forResource: "json", withExtension: "txt")
do{
let data = try Data(contentsOf: url!) // not nullable
let jsonObj = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as! Array<Dictionary<String, AnyObject>> // cast from jsonObj to Dictionary, then to Array
for t in jsonObj {
print("Her name is \(t["name"] as! String)")
print("she got \(t["height"] as! Int) cm in height")
// let define and if
if let w = t["weight"]{
print("and weight is between \(w["min"] as! Int)")