当前位置:网站首页>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)
}
}
边栏推荐
- lua 函数
- 力扣解法汇总497-非重叠矩形中的随机点
- Software engineering course: Chapter 2 software problem definition and feasibility analysis after class exercises
- 阿里云oss文件上传系统
- 力扣解法汇总450-删除二叉搜索树中的节点
- Smartbi helps you solve the problem of losing high-value customers
- 打包一个包含手表端应用的手机端APK应用—Ticwear
- Applets 111111
- PHP security development 13 column module of blog system
- 力扣解法汇总398-随机数索引
猜你喜欢

Operating mechanism of Google ads bidding

Explore performance optimization! Performance improvement from 2 months to 4 hours!

Glfwpollevents() program crash

Knowledge points of mall development

BaseDexClassLoader那些事

Three main factors determining advertising quality

Four schemes for redis to implement message queue

The release of star ring kundb 2.2 provides a new choice for business systems with high concurrent transactions and queries

Almost all schools will ask for the second round exam! Come in and recite the answer!

Installing MySQL version 5.5 database for Linux (centos6)
随机推荐
Don't miss it! Five large data visualization screens that HR must collect
Applets 111111
The most comprehensive redis transaction control in 2022 (with illustration)
没有文笔,大家多多包涵
Graphic data analysis | data cleaning and pretreatment
MySQL table common operation mind map
"China Dongxin Cup" the fourth programming competition of Guangxi University (synchronous competition)
力扣解法汇总675-为高尔夫比赛砍树
如何定位关键词使得广告精准投放。
Is the bidding price fixed for each click?
Software engineering - system flow chart
Redis實現消息隊列的4種方案
Explore performance optimization! Performance improvement from 2 months to 4 hours!
如何让杀毒软件停止屏蔽某个网页?以GDATA为例
Comprehensive quality of teaching resources in the second half of 2019 - subjective questions
Software engineering course: Chapter 2 software problem definition and feasibility analysis after class exercises
Master of a famous school has been working hard for 5 years. AI has no paper. How can the tutor free range?
Introduction to SVM
Linux (centos7) installer mysql - 5.7
Graphic data analysis | business cognition and data exploration