## YouTube JSON API
这是YouTube JSON API响应对象的示例。你可以从中学到更多关于YouTube JSON API的内容:[http://code.google.com/apis/youtube/2.0/developers_guide_jsonc.html](http://code.google.com/apis/youtube/2.0/developers_guide_jsonc.html)
~~~
{
"apiVersion": "2.0",
"data": {
"updated": "2010-02-04T19:29:54.001Z",
"totalItems": 6741,
"startIndex": 1,
"itemsPerPage": 1,
"items": [
{
"id": "BGODurRfVv4",
"uploaded": "2009-11-17T20:10:06.000Z",
"updated": "2010-02-04T06:25:57.000Z",
"uploader": "docchat",
"category": "Animals",
"title": "From service dog to SURFice dog",
"description": "Surf dog Ricochets inspirational video ...",
"tags": [
"Surf dog",
"dog surfing",
"dog",
"golden retriever",
],
"thumbnail": {
"default": "http://i.ytimg.com/vi/BGODurRfVv4/default.jpg",
"hqDefault": "http://i.ytimg.com/vi/BGODurRfVv4/hqdefault.jpg"
},
"player": {
"default": "http://www.youtube.com/watch?v=BGODurRfVv4&feature=youtube_gdata",
"mobile": "http://m.youtube.com/details?v=BGODurRfVv4"
},
"content": {
"1": "rtsp://v5.cache6.c.youtube.com/CiILENy73wIaGQn-Vl-0uoNjBBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp",
"5": "http://www.youtube.com/v/BGODurRfVv4?f=videos&app=youtube_gdata",
"6": "rtsp://v7.cache7.c.youtube.com/CiILENy73wIaGQn-Vl-0uoNjBBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"
},
"duration": 315,
"rating": 4.96,
"ratingCount": 2043,
"viewCount": 1781691,
"favoriteCount": 3363,
"commentCount": 1007,
"commentsAllowed": true
}
]
}
}
~~~
## 分页示例
如何将Google搜索条目作为JSON对象展现出来,对分页变量也有特别关注。
这个示例仅用作说明。下面的API实际上并不存在。
这是Google搜索结果页面的示例: [![image](https://camo.githubusercontent.com/c8ff0de46d7cb966ddae8b3350960400fdd6962d/687474703a2f2f676f6f676c652d7374796c6567756964652e676f6f676c65636f64652e636f6d2f73766e2f7472756e6b2f6a736f6e637374796c6567756964655f6578616d706c655f30312e706e67)](https://camo.githubusercontent.com/c8ff0de46d7cb966ddae8b3350960400fdd6962d/687474703a2f2f676f6f676c652d7374796c6567756964652e676f6f676c65636f64652e636f6d2f73766e2f7472756e6b2f6a736f6e637374796c6567756964655f6578616d706c655f30312e706e67)
[![image](https://camo.githubusercontent.com/0341a3abf1faaffd6dc67039efd964336d285f54/687474703a2f2f676f6f676c652d7374796c6567756964652e676f6f676c65636f64652e636f6d2f73766e2f7472756e6b2f6a736f6e637374796c6567756964655f6578616d706c655f30322e706e67)](https://camo.githubusercontent.com/0341a3abf1faaffd6dc67039efd964336d285f54/687474703a2f2f676f6f676c652d7374796c6567756964652e676f6f676c65636f64652e636f6d2f73766e2f7472756e6b2f6a736f6e637374796c6567756964655f6578616d706c655f30322e706e67)
这是该页面JSON形式的呈现:
~~~
{
"apiVersion": "2.1",
"id": "1",
"data": {
"query": "chicago style pizza",
"time": "0.1",
"currentItemCount": 10,
"itemsPerPage": 10,
"startIndex": 11,
"totalItems": 2700000,
"nextLink": "http://www.google.com/search?hl=en&q=chicago+style+pizza&start=20&sa=N"
"previousLink": "http://www.google.com/search?hl=en&q=chicago+style+pizza&start=0&sa=N",
"pagingLinkTemplate": "http://www.google.com/search/hl=en&q=chicago+style+pizza&start={index}&sa=N",
"items": [
{
"title": "Pizz'a Chicago Home Page"
// More fields for the search results
}
// More search results
]
}
}
~~~
这是如何展现屏幕截图中的色块的例子(背景颜色对应下图中的颜色)
* Results 11 - 20 of about 2,700,000 = startIndex
* Results 11 - 20 of about 2,700,000 = startIndex + currentItemCount - 1
* Results 11 - 20 of about 2,700,000 = totalItems
* Search results = items (formatted appropriately)
* Previous/Next = previousLink / nextLink
* Numbered links in "Gooooooooooogle" = Derived from "pageLinkTemplate". The developer is responsible for calculating the values for {index} and substituting those values into the "pageLinkTemplate". The pageLinkTemplate's {index} variable is calculated as follows:
* Index #1 = 0 * itemsPerPage = 0
* Index #2 = 2 * itemsPerPage = 10
* Index #3 = 3 * itemsPerPage = 20
* Index #N = N * itemsPerPage
- Google 开源项目风格指南 (中文版)
- C++ 风格指南
- 0. 扉页
- 1. 头文件
- 2. 作用域
- 3. 类
- 4. 来自 Google 的奇技
- 5. 其他 C++ 特性
- 6. 命名约定
- 7. 注释
- 8. 格式
- 9. 规则特例
- 10. 结束语
- Objective-C 风格指南
- Google Objective-C Style Guide 中文版
- 留白和格式
- 命名
- 注释
- Cocoa 和 Objective-C 特性
- Cocoa 模式
- Python 风格指南
- Google Python 风格指南 - 中文版
- 背景
- Python语言规范
- Python风格规范
- 临别赠言
- JSON 风格指南
- 简介
- 定义
- 一般准则
- 属性名准则
- 属性值准则
- 属性值数据类型
- JSON结构和保留属性名
- 顶级保留属性名称
- data对象的保留属性名
- 用于分页的保留属性名
- 用于链接的保留属性名
- 错误对象中的保留属性名
- 属性顺序
- 示例
- 附录