什么是JSON——Atlas采用的数据传输格式
在学习Atlas时已经n次看到JSON这个名词,今天特地查了一下。
原来JSON是一种用基于文本的数据描述格式,全称“JavaScript Object Notiation”,类似于XML和SOAP,同样具有跨平台的特性。
我举一个小例子,
先看看用Xml描述论坛中的帖子:
<posts>
<post>
<id>1</id>
<title>帖子1</title>
<content>内容</content>
<posterId>13</posterId>
</post>
<post>
<id>2</id>
<title>帖子2</title>
<content>内容</content>
<posterId>13</posterId>
</post>
</posts>
使用JSON:
{posts:[
{
id:1,
title:"帖子1",
content:"内容",
posterId:13
},
{
id:2,
title:"帖子2",
content:"内容",
posterId:13
}
]};
Atlas从Beta版开始全面用JSON格式描述服务器和客户端之间传输的数据,Microsoft.Web.Script.Services命名空间提供这方面的支持。
以下提供一点参考资料,仅供大家对JSON进行浅显的了解。