swift3.0 data转String 打印输出

前端之家收集整理的这篇文章主要介绍了swift3.0 data转String 打印输出前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。


 /*
         打印json数据
         */
        LJDownLoadNetImage.request("GET",url: "http://jsonplaceholder.typicode.com/users/1") { (data,respond,error) in
            data转String
            let str = String(data:data!,encoding: String.Encoding.utf8)!
            print(str)

        }

打印结果
{
  "id": 1,"name": "Leanne Graham","username": "Bret","email": "Sincere@april.biz","address": {
    "street": "Kulas Light","suite": "Apt. 556","city": "Gwenborough","zipcode": "92998-3874","geo": {
      "lat": "-37.3159","lng": "81.1496"
    }
  },"phone": "1-770-736-8031 x56442","website": "hildegard.org","company": {
    "name": "Romaguera-Crona","catchPhrase": "Multi-layered client-server neural-net","bs": "harness real-time e-markets"
  }
}
原文链接:https://www.f2er.com/swift/321502.html

猜你在找的Swift相关文章