Swift 4 The data couldn’t be read because it isn’t in the correct format

前端 未结 2 1526
甜味超标
甜味超标 2021-01-12 19:23

I am developing a project to learn how to parse JSON. I am trying to parse JSON to a struct. I am trying to do it using the code that come

2条回答
  •  时光说笑
    2021-01-12 19:59

    Try this

    let gitData = try decoder.decode(Root.self, from: data!)
    

    Traverse through your data

    for singleData in gitData.data where (singleData.name ?? "") == "Cafe" {
        print(singleData.image)
    }
    

提交回复
热议问题