当前位置:网站首页>SwiftyJSON解析本地JSON文件
SwiftyJSON解析本地JSON文件
2022-06-12 02:06:00 【JH_Cao】
SwiftyJSON
1. 本地JSON文件
[
{
"name": "hangge",
"age": 100,
"phones": [
{
"name": "公司",
"number": "123456"
},
{
"name": "家庭",
"number": "001"
}
]
},
{
"name": "big boss",
"age": 1,
"phones": [
{
"name": "公司",
"number": "111111"
}
]
}
]
2. demo
override func viewDidLoad() {
super.viewDidLoad()
let path = Bundle.main.path(forResource: "testData", ofType: "json")!
let testData = NSData(contentsOfFile: path)
let json = try! JSON(data: testData! as Data)
if let number = json[0]["phones"][0]["number"].string {
print("電話:",number)
}
}
边栏推荐
猜你喜欢

Linux(CentOS6)安装MySQL5.5版本数据库

Spiral matrix (skill)

商城开发知识点

2022 blind box applet app has become a new drainage outlet for enterprises

Redis實現消息隊列的4種方案

How WPS inserts a directory and the operating steps for quickly inserting a directory

How to stop anti-virus software from blocking a web page? Take gdata as an example

Software engineering - system flow chart

Smartbi helps you solve the problem of losing high-value customers

SQL calculates KS, AUC, IV, psi and other risk control model indicators
随机推荐
力扣解法汇总-剑指 Offer II 114. 外星文字典
Basedexclassloader
力扣解法汇总965-单值二叉树
Does the virtual host have independent IP
How to locate keywords to make advertising accurate.
How to stop anti-virus software from blocking a web page? Take gdata as an example
超图倾斜数据合并根节点后转3dtiles
微信公众号开发地理位置坐标的转换
How to maximize the use of various matching methods—— Google SEM
Redis實現消息隊列的4種方案
如何让杀毒软件停止屏蔽某个网页?以GDATA为例
What insurance products can you buy at the age of 60?
力扣解法汇总821-字符的最短距离
Don't miss it! Five large data visualization screens that HR must collect
Is there a female Bluetooth headset suitable for girls? 38 Bluetooth headsets worth getting started
力扣解法汇总450-删除二叉搜索树中的节点
力扣解法汇总824-山羊拉丁文
“中国东信杯”广西大学第四届程序设计竞赛(同步赛)
Metaverse × How will smart cities develop?
C language programming classic games - minesweeping