网络编程:Json解析
来源:互联网 发布:巨森网络 编辑:程序博客网 时间:2024/04/30 10:05
在k780.com上获取数据:
1.生成二维码:
let url =NSURL(string:"http://api.k780.com:88/?app=qr.get&data=testqqqq&level=L&size=6")!
let request = NSURLRequest(URL: url)
NSURLConnection.sendAsynchronousRequest(request, queue:NSOperationQueue()) { (_, data, error) ->Void in
if error == nil {
dispatch_async(dispatch_get_main_queue(), { () ->Void in
self.qrcodeImageView.image =UIImage(data: data)
})
}
}
let weatherRequest =NSURLRequest(URL:NSURL(string:"http://api.k780.com:88/? app=weather.future&weaid=1&&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json)!)
NSURLConnection.sendAsynchronousRequest(weatherRequest, queue:NSOperationQueue()) { (_, data, error) -> Void in
if error == nil {
if let json =NSJSONSerialization.JSONObjectWithData(data, options:nil, error: nil)as? NSDictionary {
if let result = json.valueForKey("result")as? NSArray {
if let resultToday = result[0]as? NSDictionary{
dispatch_async(dispatch_get_main_queue(), { () ->Void in
self.locationLable.text = resultToday["citynm"]as? String
self.weatherLable.text = resultToday["weather"]as? String
self.tempLable.text = resultToday["temperature"]as? String
})
}
}
}
}
}
- 网络编程:Json解析
- 网络编程--JSON数据解析
- iOS网络编程3—JSON解析
- Android网络编程之JSON解析
- 网络编程-json数据的解析
- iOS 网络编程 (四)JSON解析
- iOS网络编程开发—JSON解析与XML解析
- iOS网络编程:网络交互数据格式解析之json
- Android网络与数据存储——网络编程数据处理(网络请求解析Json,解析xml)
- Android 网络编程之 XML 和 JSON 解析
- Android之网络编程(四)解析 JSON 格式数据
- iOS开发之网络编程:XML,JSon解析
- iOS开发之网络编程篇四:XML,JSon解析
- iOS网络编程4--使用SwiftyJSON解析JSON数据
- android网络编程之json传输数据以及解析方式
- iOS编程学习二十一(网络和JSON解析)
- 网络Json解析
- Json网络解析
- Android: NDK编程入门笔记
- 2015年第十二周项目四:点,圆类的关系
- JQuery判断radio是否选中,获取选中值
- mysql一些常用命令
- 论MySQL何时使用索引,何时不使用索引
- 网络编程:Json解析
- CSS解决图片下面有空隙的简单方法
- linux 技巧:使用 screen 管理你的远程会话
- 面向对象的三大支柱:继承,封装,多态
- (157A)
- PHP 下载功能源码
- 第13周 《C++语言基础》程序阅读——多态性与抽象类 (4)
- 第十三周阅读项目(1):虚函数
- 葛教你如何成为顶尖互联网产品经理