惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
博客园 - 三生石上(FineUI控件)
爱范儿
爱范儿
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
Engineering at Meta
Engineering at Meta
有赞技术团队
有赞技术团队
月光博客
月光博客
M
MIT News - Artificial intelligence
V
Visual Studio Blog
Stack Overflow Blog
Stack Overflow Blog
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
I
InfoQ
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
雷峰网
雷峰网

博客园 - 小灰灰开始整活儿啦

喔去,litellm 竟然被投毒了,赶紧检查你的机器中招了没有 KMP跨平台开发中的现状调研 [随记]iphone加粗字体 .net 序列化反序列化小节 如何获得毫秒级时间(iphone) Mac os 截屏快捷键 消灭Warning 'ClassName' may not respond to '-funcName:args' 给xcode设置快捷键 - 小灰灰开始整活儿啦 - 博客园 [转]iPhone系统常用文件夹位置 Xcode 快捷键全集[转] iphone中如何进行多线程编程[转] NSString详细介绍 Iphone UILabel显示多行文本的方法 Iphone dev -json-1- Transfer json data by Http Submitting HTTP Requests (iPhone) 不支持js的(wap2.0)手机清单 Safe characters for friendly url HTC 手机的'Length Require的Bug [编程点滴]将string 转化成enum最简单的办法。
iPhone上的JSON[转]
小灰灰开始整活儿啦 · 2010-12-08 · via 博客园 - 小灰灰开始整活儿啦

Posted on 2010-12-08 15:48  小灰灰开始整活儿啦  阅读(1030)  评论()    收藏  举报

JSON我就不多解释了,需要更多信息的朋友请到json.org上查看。

在iPhone上访问网络内容是很必须的,而一些数据就需要以某种形式储存在web服务器上。比如一个app的目录,内容,索引等等。而xml和json,plist都是比较方便的方式。

-XML在iPhone上是非常好用的,但是对复杂的数据结构使用上就不那么方便了,具体可以参阅苹果的“基于事件的XML”和“基于树的XML”编程向导

-plist是再方便不过了,不过我看最多也就是一个NSDictionary而已,复杂一些的话,数据输入上也会非常非常的麻烦。

-JSON本来是不被苹果支持的,但是有人很Nice的帮我们解决了这个问题:JSON for OBJC http://code.google.com/p/json-framework/

基本上来说,这个框架异常的简单易用,会将得到的json字符串处理成一个复杂NSDictionary对象,而每一个值都还是一个NSDictionary对象

比如:

{
"华藏净宗学会":
{
"zhaomu":
{
"name":"净宗朝暮课本",
"length":142,
"digits":3
},
"kesong":
{
"name":"净宗共修课本",
"length":75,
"digits":2
}
},
"生命基金会":
{
"dabei88":
{
"name":"大悲出相图",
"length":88,
"digits":2
}
}
}

就会转换为一个复杂无比的NSDictionary:

[[NSDictionary alloc]
initWithObjects:[NSArray
arrayWithObjects:
[NSDictionary
dictionaryWithObjects:[NSArray
arrayWithObjects:
[NSDictionary
dictionaryWithObjects:[NSArray
arrayWithObjects:
@"净宗朝暮课本",
@"142",
@"3",nil]
forKeys:
[NSArray arrayWithObjects:
@"name",
@"length",
@"digits",nil]],
[NSDictionary
dictionaryWithObjects:[NSArray
arrayWithObjects:
@"净宗共修课本",
@"75",
@"2",nil]
forKeys:
[NSArray arrayWithObjects:
@"name",
@"length",
@"digits",nil]],nil]
forKeys:[NSArray arrayWithObjects:@"zhaomu",@"kesong",nil]],
[NSDictionary
dictionaryWithObjects:[NSArray
arrayWithObjects:
[NSDictionary
dictionaryWithObjects:[NSArray
arrayWithObjects:
@"大悲出相图",
@"88",
@"2",nil]
forKeys:
[NSArray arrayWithObjects:
@"name",
@"length",
@"digits",nil]],nil]
forKeys:[NSArray arrayWithObjects:@"dabei88",nil]],nil]
forKeys:[NSArray arrayWithObjects:@"华藏净宗学会",@"生命基金会",nil]];

我是非常佩服自己能打出来上面的巨大无比的定义式。。。。没有编译错误

不管怎么样,转换后,在系统中就可以非常方便的使用json的键值结构信息咯~!!!