//

// ViewController.swift

// json读写

//

// Created by mac on 15/7/14.

// Copyright (c) 2015年 fangyuhao. All rights reserved.

//

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var json: AnyObject? = NSJSONSerialization.JSONObjectWithData(NSData(contentsOfURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("obj", ofType: "json")!)!)!, options: NSJSONReadingOptions.allZeros, error: nil) if let lang: AnyObject = json?.objectForKey("language") {
println(lang)
}
//生成
var dict = ["name":"jikexueyuan","age":1]
var jsonData = NSJSONSerialization.dataWithJSONObject(dict, options: NSJSONWritingOptions.allZeros, error: nil)
if let str = NSString(data: jsonData!, encoding: NSUTF8StringEncoding){
println(str)
} } override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

}

json 读写 swift的更多相关文章

  1. UE4 的json读写方式

    转自:http://blog.csdn.net/cartzhang/article/details/41009343 JSON 的解析有很多开源库.UE4的JSON使用在代码的Public->S ...

  2. UE4的JSON读写方式<一>

    声明:全部权利保留. 转载必须说明出处:http://blog.csdn.net/cartzhang/article/details/41009343 UE4的Json的解析博客地址: http:// ...

  3. UE4的JSON读写方式<一>

    声明:所有权利保留. 转载必须说明出处:http://blog.csdn.net/cartzhang/article/details/41009343 UE4的Json的解析博客地址: http:// ...

  4. UE4的JSON读写方式<二>

    声明:所有权利保留. 转载必须说明出处:http://blog.csdn.net/cartzhang/article/details/43794409 Json的Writer博客地址: http:// ...

  5. Python中异常和JSON读写数据

    异常可以防止出现一些不友好的信息返回给用户,有助于提升程序的可用性,在java中通过try ... catch ... finally来处理异常,在Python中通过try ... except .. ...

  6. 文件读写 swift

    // // ViewController.swift // 文件读写 // // Created by mac on 15/7/12. // Copyright (c) 2015年 fangyuhao ...

  7. UserDefault 用户首选项读写 swift

    // // ViewController.swift // 首选项数据读写 // // Created by mac on 15/7/12. // Copyright (c) 2015年 fangyu ...

  8. golang json 读写配置文件

    package main import ( "encoding/json" "fmt" "os" ) type configuration ...

  9. C# 使用Newtonsoft.Json读写Json文件

    { "CAN": false, "AccCode": 4294901856, "Id": 768, "BPointMove&quo ...

随机推荐

  1. (笔记)angular 多选按钮

  2. 码农谷 求前N项之和

    题目描述 有一分数序列:2/1.3/2.5/3.8/5.13/8.21/13.......求出这个数列的前N项之和,保留两位小数. 输入描述 N 输出描述 数列前N项和 样例 输入: 输出: 16.4 ...

  3. div模拟下拉框

    1.模拟下拉框.点击文本框在文本框下面显示一个层divList,点击divList以外的任何地方,关闭divList层 document.body.onclick = function (e) { e ...

  4. Centos6.5(final)安装gcc和g++,python以及导致问题的解决方法

    安装gcc:yum install gcc  安装g++:yum install gcc-c++ 安装python: centos默认是2.6的版本, 下载python ,我下载的是2.7.10. 1 ...

  5. Unable to write inside TEMP environment path

    安装PostgreSQL 9:Unable to write inside TEMP environment path 注册表:regedit HKEY_CLASSES_ROOT\.vbs,设置默认为 ...

  6. C#winform设置DateTimePicker的时间格式

    在对DateTimePicker进行时间格式设置时候,要先对属性Format设置为"Custom"自定义格式,然后再CustomFormat里面进行格式设置 比如"yyy ...

  7. C# 执行JS

    需引用命名空间:Microsoft.VsaMicrosoft.JScript using System; using System.Collections.Generic; using System. ...

  8. windows7安装IE11点击图标没反应

    可以通过修改 Windows 注册表的方式解决: Win+R 打开“运行”后输入 regedit 打开 注册表编辑器 打开注册表编辑器(regedit)以后,找到注册表项HKEY_CURRENT_US ...

  9. C#自定义导出数据到Excel中的类封装

    using System; using System.IO; using System.Data; using System.Collections; using System.Data.OleDb; ...

  10. for xml path('') 引发的数据不完整

    When you read Extensible Markup Language (XML) data from Microsoft SQL Server by using the SqlDataRe ...