SlideShare a Scribd company logo
JSON详解
版本:v1.1
Crifan Li
摘要
本文主要介绍了JSON的基础知识,以及在具体(Python,C#等)编程语言中,如何处理JSON,以及常见错误和
解决办法。

本文提供多种格式供:
在线阅读

HTML

1

下载(7zip压缩包)

HTML

8

HTMLs

PDF

3

HTMLs

PDF

10

2

9

CHM

4

CHM

11

TXT

5

TXT

12

RTF

6

RTF

13

WEBHELP
7

WEBHELP

HTML版本的在线地址为:
http://www.crifan.com/files/doc/docbook/json_tutorial/release/html/json_tutorial.html
有任何意见,建议,提交bug等,都欢迎去讨论组发帖讨论:
http://www.crifan.com/bbs/categories/json_tutorial/

修订历史
修订 1.1

2013-09-05

crl

1. 把之前教程的地址整理过来
2. 把Python语言总结中对应的Python的json内容整理过来

1

http://www.crifan.com/files/doc/docbook/json_tutorial/release/html/json_tutorial.html
http://www.crifan.com/files/doc/docbook/json_tutorial/release/htmls/index.html
3
http://www.crifan.com/files/doc/docbook/json_tutorial/release/pdf/json_tutorial.pdf
4
http://www.crifan.com/files/doc/docbook/json_tutorial/release/chm/json_tutorial.chm
5
http://www.crifan.com/files/doc/docbook/json_tutorial/release/txt/json_tutorial.txt
6
http://www.crifan.com/files/doc/docbook/json_tutorial/release/rtf/json_tutorial.rtf
7
http://www.crifan.com/files/doc/docbook/json_tutorial/release/webhelp/index.html
8
http://www.crifan.com/files/doc/docbook/json_tutorial/release/html/json_tutorial.html.7z
9
http://www.crifan.com/files/doc/docbook/json_tutorial/release/htmls/index.html.7z
10
http://www.crifan.com/files/doc/docbook/json_tutorial/release/pdf/json_tutorial.pdf.7z
11
http://www.crifan.com/files/doc/docbook/json_tutorial/release/chm/json_tutorial.chm.7z
12
http://www.crifan.com/files/doc/docbook/json_tutorial/release/txt/json_tutorial.txt.7z
13
http://www.crifan.com/files/doc/docbook/json_tutorial/release/rtf/json_tutorial.rtf.7z
14
http://www.crifan.com/files/doc/docbook/json_tutorial/release/webhelp/json_tutorial.webhelp.7z
2

14
JSON详解:
Crifan Li

版本:v1.1
出版日期 2013-09-05
版权 © 2013 Crifan, http://crifan.com
15

本文章遵从:署名-非商业性使用 2.5 中国大陆(CC BY-NC 2.5)

15

http://www.crifan.com/files/doc/docbook/soft_dev_basic/release/html/soft_dev_basic.html#cc_by_nc
目录
前言 ........................................................................................................................................ iv
1. 本文目的 ...................................................................................................................... iv
1. JSON简介 ............................................................................................................................ 1
2. Python中处理JSON字符串 .................................................................................................... 2
2.1. json中如果内容中包含单引号或双引号如何处理 ............................................................ 2
2.2. 字典类型的json字符串中的key一定要用双引号括起来 ................................................... 2
2.3. 字典类型的json字符串中的key要用双引号,而不能用单引号 ......................................... 2
3. C#中处理JSON字符串 ........................................................................................................... 4
4. 常见的JSON相关的问题及解决办法 ........................................................................................ 5
4.1. 给JSON添加注释 ........................................................................................................ 5
4.2. JSON中的字符串被括起来的,只能是双引号,不能是单引号 ......................................... 5
4.3. JSON中的字符串中不能包含非法字符 .......................................................................... 5
4.4. JSON中的列表变量内的最后位置,不能有多余的逗号 ................................................... 5
4.5. 要注意JSON字符串的编码 ........................................................................................... 5
参考书目 .................................................................................................................................. 6

iii
前言
1. 本文目的
本文目的在于详细解释一下JSON方面的知识。

iv
第 1 章 JSON简介
相关旧帖
【整理】什么是JSON+如何处理JSON字符串

1

1

http://www.crifan.com/summary_what_is_json_and_how_to_process_json_string

1
第 2 章 Python中处理JSON字符串
相关旧帖
【整理】什么是JSON+如何处理JSON字符串

1

【整理】Python中将(字典,列表等)变量格式化成(漂亮的,树形的,带缩进
2
的,JSON方式的)字符串输出
【已解决】用BeautifulSoup解析Html格式的Json字符串

3

Python中,有专门的JSON处理模块,名字就叫做:json

2.1. json中如果内容中包含单引号或双引号如何
处理
如果json字符串的内容中包含单引号或双引号,直接用json.loads去转换的话,则会导致出错。
解决办法是,把所含的(用双引号括起来的)内容中单引号或双引号前,加上反斜杠即可。
以双引号为例,即,从
"key":"value incldue " "
变为
"key":"value incldue " "

2.2. 字典类型的json字符串中的key一定要用双
引号括起来
json字符串是字典变量类型的字符串的时候,对应字典中的key部分,是需要用双引号括起来的,否则
json.loads会出错的。
详情参看:【已解决】Python中用json.loads去解析字符串出错:ValueError: Expecting property
4
name: line 1 column 51 (char 51)

2.3. 字典类型的json字符串中的key要用双引
号,而不能用单引号
json字符串是字典变量类型的字符串的时候,对应字典中的key部分,注意是用双引号括起来,而不能
是单引号,否则也是会导致json.loads出错的。
比如对于字符串变量timeFillingInfoJson:
{'2012' : {"month" : [0,0,0,0,0,0,0,-1,-1,-1,-1,-1],"totalCount" : '0'},'2011' :
{"month" : [0,0,0,0,0,0,0,0,0,0,0,0],"totalCount" : '0'},'2010' : {"month" :
1

http://www.crifan.com/summary_what_is_json_and_how_to_process_json_string
http://www.crifan.com/format_dictionary_list_variable_into_prettified_tree_like_with_indent_json_string_then_output
3
http://www.crifan.com/use_beautifulsoup_parse_the_backslash_style_html_json_string
4
http://www.crifan.com/python_json_loads_valueerror_expecting_property_name/
2

2
Python中处理JSON字符串
[5,21,22,20,11,7,8,11,12,0,0,1],"totalCount" : '118'},'2009' : {"month" :
[0,13,9,20,63,32,35,32,24,39,15,6],"totalCount" : '288'},'2008' : {"month" :
[6,40,83,66,35,35,11,5,3,4,0,1],"totalCount" : '289'},'2007' : {"month" :
[-1,-1,-1,6,0,19,10,8,3,41,47,44],"totalCount" : '178'}}
用代码:
timeFillingInfoDict = json.loads(timeFillingInfoJson);
logging.info("timeFillingInfoDict=%s", timeFillingInfoDict);
去解析会出错:
ValueError: Expecting property name: line 1 column 1 (char 1)
而把单引号替换为双引号后:
{"2012" : {"month" : [0,0,0,0,0,0,0,-1,-1,-1,-1,-1],"totalCount" : "0"},"2011" :
{"month" : [0,0,0,0,0,0,0,0,0,0,0,0],"totalCount" : "0"},"2010" : {"month" :
[5,21,22,20,11,7,8,11,12,0,0,1],"totalCount" : "118"},"2009" : {"month" :
[0,13,9,20,63,32,35,32,24,39,15,6],"totalCount" : "288"},"2008" : {"month" :
[6,40,83,66,35,35,11,5,3,4,0,1],"totalCount" : "289"},"2007" : {"month" :
[-1,-1,-1,6,0,19,10,8,3,41,47,44],"totalCount" : "178"}}
就可以正常解析,得到对应的dict变量了:
timeFillingInfoDict={u'2007': {u'totalCount': u'178', u'month': [-1, -1, -1, 6, 0, 19, 10, 8, 3,
41, 47, 44]}, u'2008': {u'totalCount': u'289', u'month': [6, 40, 83, 66, 35, 35, 11, 5, 3, 4, 0, 1]},
u'2009': {u'totalCount': u'288', u'month': [0, 13, 9, 20, 63, 32, 35, 32, 24, 39, 15, 6]}, u'2011':
{u'totalCount': u'0', u'month': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, u'2010': {u'totalCount': u'118',
u'month': [5, 21, 22, 20, 11, 7, 8, 11, 12, 0, 0, 1]}, u'2012': {u'totalCount': u'0', u'month': [0, 0, 0,
0, 0, 0, 0, -1, -1, -1, -1, -1]}}

dict类型json字符串中的key,如果用单引号,是不行的
另外,也去尝试过了,把双引号都替换为单引号:
timeFillingInfoJson = timeFillingInfoJson.replace('"', "'");
timeFillingInfoDict = json.loads(timeFillingInfoJson);
logging.info("timeFillingInfoDict=%s", timeFillingInfoDict);
结果同样会出错的:
ValueError: Expecting property name: line 1 column 1 (char 1)
所以,看来dict的json字符串中的key,必须是用双引号括起来的,不能少了双引号,也不
能是单引号,只能是双引号。

3
第 3 章 C#中处理JSON字符串
相关旧帖
【已放弃】C#中实现将Json字符串转换为变量

1

1

http://www.crifan.com/convert_json_string_to_object_variable_in_csharp

4
第 4 章 常见的JSON相关的问题及解决
办法
4.1. 给JSON添加注释
相关旧帖
【部分解决】Json中添加注释

1

4.2. JSON中的字符串被括起来的,只能是双引
号,不能是单引号
相关旧帖
【已解决】Python中使用json.loads解码字符串时出错:ValueError: Expecting property
2
name: line 1 column 1 (char 1)

4.3. JSON中的字符串中不能包含非法字符
相关旧帖
【已解决】Python中json.loads解析包含n的字符串会出错

3

4.4. JSON中的列表变量内的最后位置,不能有
多余的逗号
相关旧帖
【已解决】Python中用json.loads解码字符串出错:ValueError: No JSON object could
4
be decoded

4.5. 要注意JSON字符串的编码
相关旧帖
【经验记录】Python中json.loads的时候出错->要注意要解码的Json字符的编码

5

1

http://www.crifan.com/add_comments_for_json
http://www.crifan.com/python_json_loads_valueerror_expecting_property_name_line_1_column_1_char_1
http://www.crifan.com/use_python_json_loads_parse_string_contain_newline_will_fail_error
4
http://www.crifan.com/python_json_loads_valueerror_no_json_object_could_be_decoded
5
http://www.crifan.com/notation_about_use_python_json_loads
2
3

5
参考书目
1

[1] python初级教程:入门详解

1

http://www.crifan.com/files/doc/docbook/python_beginner_tutorial/release/html/python_beginner_tutorial.html

6

More Related Content

PPT
Mongo快速入门
PDF
Symbology upc
PDF
Usb hid
PDF
Usb basic
PDF
Docbook dev note
PDF
Dma pl08x analysis
PDF
Cross compile
PDF
Dma pl08x analysis
Mongo快速入门
Symbology upc
Usb hid
Usb basic
Docbook dev note
Dma pl08x analysis
Cross compile
Dma pl08x analysis

Viewers also liked (8)

PDF
Arm vs mips
PDF
Virtualbox tutorial
PDF
Symbology code128
PDF
Regular expression
PDF
Symbology gs1128
PDF
Crifanlib csharp
PDF
Crifanlib python
PDF
Buy house
Arm vs mips
Virtualbox tutorial
Symbology code128
Regular expression
Symbology gs1128
Crifanlib csharp
Crifanlib python
Buy house
Ad

Similar to Json tutorial (18)

PDF
Python topic re
PDF
第七章解答
PDF
Python summary
PPT
手机腾讯网Js资源版本增量更新方案w3ctech
PDF
手把手教你 R 語言分析實務
PDF
Ch7 習題
PDF
Csharp summary
PDF
Csharp summary
PDF
Python匯出入csv以及繪製圖表初稿
PPTX
Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509
PPT
自下而上的数据仓库构建方法
PPTX
Fastjson那些事
PDF
Ch8 習題
PDF
Python topic str_encoding
PDF
Schema-Less Columnar Storage Format Yosegi
PPT
Web3.0 与人工智能
PDF
程式人雜誌 -- 2015 年5月號
PDF
程式人雜誌 2015年五月
Python topic re
第七章解答
Python summary
手机腾讯网Js资源版本增量更新方案w3ctech
手把手教你 R 語言分析實務
Ch7 習題
Csharp summary
Csharp summary
Python匯出入csv以及繪製圖表初稿
Linux c++ 编程之链接与装载 -基础篇--v0.3--20120509
自下而上的数据仓库构建方法
Fastjson那些事
Ch8 習題
Python topic str_encoding
Schema-Less Columnar Storage Format Yosegi
Web3.0 与人工智能
程式人雜誌 -- 2015 年5月號
程式人雜誌 2015年五月
Ad

More from cri fan (20)

PDF
Scientific network summary
PDF
Virutal machine tutorial
PDF
Usb disk driver
PDF
Uboot starts analysis
PDF
Symbology plessey
PDF
Soft dev basic
PDF
Runtime upgrade linux
PDF
Rec soft npp
PDF
Python intermediate tutorial
PDF
Python beginner tutorial
PDF
Programming language basic
PDF
Nand get type
PDF
Mpeg vbr
PDF
Linux wireless
PDF
Linux nand driver
PDF
Language summary
PDF
Interrupt related
PDF
Hardware basic
PDF
Firmware download
PDF
Fieldbus intro
Scientific network summary
Virutal machine tutorial
Usb disk driver
Uboot starts analysis
Symbology plessey
Soft dev basic
Runtime upgrade linux
Rec soft npp
Python intermediate tutorial
Python beginner tutorial
Programming language basic
Nand get type
Mpeg vbr
Linux wireless
Linux nand driver
Language summary
Interrupt related
Hardware basic
Firmware download
Fieldbus intro

Json tutorial

  • 1. JSON详解 版本:v1.1 Crifan Li 摘要 本文主要介绍了JSON的基础知识,以及在具体(Python,C#等)编程语言中,如何处理JSON,以及常见错误和 解决办法。 本文提供多种格式供: 在线阅读 HTML 1 下载(7zip压缩包) HTML 8 HTMLs PDF 3 HTMLs PDF 10 2 9 CHM 4 CHM 11 TXT 5 TXT 12 RTF 6 RTF 13 WEBHELP 7 WEBHELP HTML版本的在线地址为: http://www.crifan.com/files/doc/docbook/json_tutorial/release/html/json_tutorial.html 有任何意见,建议,提交bug等,都欢迎去讨论组发帖讨论: http://www.crifan.com/bbs/categories/json_tutorial/ 修订历史 修订 1.1 2013-09-05 crl 1. 把之前教程的地址整理过来 2. 把Python语言总结中对应的Python的json内容整理过来 1 http://www.crifan.com/files/doc/docbook/json_tutorial/release/html/json_tutorial.html http://www.crifan.com/files/doc/docbook/json_tutorial/release/htmls/index.html 3 http://www.crifan.com/files/doc/docbook/json_tutorial/release/pdf/json_tutorial.pdf 4 http://www.crifan.com/files/doc/docbook/json_tutorial/release/chm/json_tutorial.chm 5 http://www.crifan.com/files/doc/docbook/json_tutorial/release/txt/json_tutorial.txt 6 http://www.crifan.com/files/doc/docbook/json_tutorial/release/rtf/json_tutorial.rtf 7 http://www.crifan.com/files/doc/docbook/json_tutorial/release/webhelp/index.html 8 http://www.crifan.com/files/doc/docbook/json_tutorial/release/html/json_tutorial.html.7z 9 http://www.crifan.com/files/doc/docbook/json_tutorial/release/htmls/index.html.7z 10 http://www.crifan.com/files/doc/docbook/json_tutorial/release/pdf/json_tutorial.pdf.7z 11 http://www.crifan.com/files/doc/docbook/json_tutorial/release/chm/json_tutorial.chm.7z 12 http://www.crifan.com/files/doc/docbook/json_tutorial/release/txt/json_tutorial.txt.7z 13 http://www.crifan.com/files/doc/docbook/json_tutorial/release/rtf/json_tutorial.rtf.7z 14 http://www.crifan.com/files/doc/docbook/json_tutorial/release/webhelp/json_tutorial.webhelp.7z 2 14
  • 2. JSON详解: Crifan Li 版本:v1.1 出版日期 2013-09-05 版权 © 2013 Crifan, http://crifan.com 15 本文章遵从:署名-非商业性使用 2.5 中国大陆(CC BY-NC 2.5) 15 http://www.crifan.com/files/doc/docbook/soft_dev_basic/release/html/soft_dev_basic.html#cc_by_nc
  • 3. 目录 前言 ........................................................................................................................................ iv 1. 本文目的 ...................................................................................................................... iv 1. JSON简介 ............................................................................................................................ 1 2. Python中处理JSON字符串 .................................................................................................... 2 2.1. json中如果内容中包含单引号或双引号如何处理 ............................................................ 2 2.2. 字典类型的json字符串中的key一定要用双引号括起来 ................................................... 2 2.3. 字典类型的json字符串中的key要用双引号,而不能用单引号 ......................................... 2 3. C#中处理JSON字符串 ........................................................................................................... 4 4. 常见的JSON相关的问题及解决办法 ........................................................................................ 5 4.1. 给JSON添加注释 ........................................................................................................ 5 4.2. JSON中的字符串被括起来的,只能是双引号,不能是单引号 ......................................... 5 4.3. JSON中的字符串中不能包含非法字符 .......................................................................... 5 4.4. JSON中的列表变量内的最后位置,不能有多余的逗号 ................................................... 5 4.5. 要注意JSON字符串的编码 ........................................................................................... 5 参考书目 .................................................................................................................................. 6 iii
  • 5. 第 1 章 JSON简介 相关旧帖 【整理】什么是JSON+如何处理JSON字符串 1 1 http://www.crifan.com/summary_what_is_json_and_how_to_process_json_string 1
  • 6. 第 2 章 Python中处理JSON字符串 相关旧帖 【整理】什么是JSON+如何处理JSON字符串 1 【整理】Python中将(字典,列表等)变量格式化成(漂亮的,树形的,带缩进 2 的,JSON方式的)字符串输出 【已解决】用BeautifulSoup解析Html格式的Json字符串 3 Python中,有专门的JSON处理模块,名字就叫做:json 2.1. json中如果内容中包含单引号或双引号如何 处理 如果json字符串的内容中包含单引号或双引号,直接用json.loads去转换的话,则会导致出错。 解决办法是,把所含的(用双引号括起来的)内容中单引号或双引号前,加上反斜杠即可。 以双引号为例,即,从 "key":"value incldue " " 变为 "key":"value incldue " " 2.2. 字典类型的json字符串中的key一定要用双 引号括起来 json字符串是字典变量类型的字符串的时候,对应字典中的key部分,是需要用双引号括起来的,否则 json.loads会出错的。 详情参看:【已解决】Python中用json.loads去解析字符串出错:ValueError: Expecting property 4 name: line 1 column 51 (char 51) 2.3. 字典类型的json字符串中的key要用双引 号,而不能用单引号 json字符串是字典变量类型的字符串的时候,对应字典中的key部分,注意是用双引号括起来,而不能 是单引号,否则也是会导致json.loads出错的。 比如对于字符串变量timeFillingInfoJson: {'2012' : {"month" : [0,0,0,0,0,0,0,-1,-1,-1,-1,-1],"totalCount" : '0'},'2011' : {"month" : [0,0,0,0,0,0,0,0,0,0,0,0],"totalCount" : '0'},'2010' : {"month" : 1 http://www.crifan.com/summary_what_is_json_and_how_to_process_json_string http://www.crifan.com/format_dictionary_list_variable_into_prettified_tree_like_with_indent_json_string_then_output 3 http://www.crifan.com/use_beautifulsoup_parse_the_backslash_style_html_json_string 4 http://www.crifan.com/python_json_loads_valueerror_expecting_property_name/ 2 2
  • 7. Python中处理JSON字符串 [5,21,22,20,11,7,8,11,12,0,0,1],"totalCount" : '118'},'2009' : {"month" : [0,13,9,20,63,32,35,32,24,39,15,6],"totalCount" : '288'},'2008' : {"month" : [6,40,83,66,35,35,11,5,3,4,0,1],"totalCount" : '289'},'2007' : {"month" : [-1,-1,-1,6,0,19,10,8,3,41,47,44],"totalCount" : '178'}} 用代码: timeFillingInfoDict = json.loads(timeFillingInfoJson); logging.info("timeFillingInfoDict=%s", timeFillingInfoDict); 去解析会出错: ValueError: Expecting property name: line 1 column 1 (char 1) 而把单引号替换为双引号后: {"2012" : {"month" : [0,0,0,0,0,0,0,-1,-1,-1,-1,-1],"totalCount" : "0"},"2011" : {"month" : [0,0,0,0,0,0,0,0,0,0,0,0],"totalCount" : "0"},"2010" : {"month" : [5,21,22,20,11,7,8,11,12,0,0,1],"totalCount" : "118"},"2009" : {"month" : [0,13,9,20,63,32,35,32,24,39,15,6],"totalCount" : "288"},"2008" : {"month" : [6,40,83,66,35,35,11,5,3,4,0,1],"totalCount" : "289"},"2007" : {"month" : [-1,-1,-1,6,0,19,10,8,3,41,47,44],"totalCount" : "178"}} 就可以正常解析,得到对应的dict变量了: timeFillingInfoDict={u'2007': {u'totalCount': u'178', u'month': [-1, -1, -1, 6, 0, 19, 10, 8, 3, 41, 47, 44]}, u'2008': {u'totalCount': u'289', u'month': [6, 40, 83, 66, 35, 35, 11, 5, 3, 4, 0, 1]}, u'2009': {u'totalCount': u'288', u'month': [0, 13, 9, 20, 63, 32, 35, 32, 24, 39, 15, 6]}, u'2011': {u'totalCount': u'0', u'month': [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, u'2010': {u'totalCount': u'118', u'month': [5, 21, 22, 20, 11, 7, 8, 11, 12, 0, 0, 1]}, u'2012': {u'totalCount': u'0', u'month': [0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]}} dict类型json字符串中的key,如果用单引号,是不行的 另外,也去尝试过了,把双引号都替换为单引号: timeFillingInfoJson = timeFillingInfoJson.replace('"', "'"); timeFillingInfoDict = json.loads(timeFillingInfoJson); logging.info("timeFillingInfoDict=%s", timeFillingInfoDict); 结果同样会出错的: ValueError: Expecting property name: line 1 column 1 (char 1) 所以,看来dict的json字符串中的key,必须是用双引号括起来的,不能少了双引号,也不 能是单引号,只能是双引号。 3
  • 8. 第 3 章 C#中处理JSON字符串 相关旧帖 【已放弃】C#中实现将Json字符串转换为变量 1 1 http://www.crifan.com/convert_json_string_to_object_variable_in_csharp 4
  • 9. 第 4 章 常见的JSON相关的问题及解决 办法 4.1. 给JSON添加注释 相关旧帖 【部分解决】Json中添加注释 1 4.2. JSON中的字符串被括起来的,只能是双引 号,不能是单引号 相关旧帖 【已解决】Python中使用json.loads解码字符串时出错:ValueError: Expecting property 2 name: line 1 column 1 (char 1) 4.3. JSON中的字符串中不能包含非法字符 相关旧帖 【已解决】Python中json.loads解析包含n的字符串会出错 3 4.4. JSON中的列表变量内的最后位置,不能有 多余的逗号 相关旧帖 【已解决】Python中用json.loads解码字符串出错:ValueError: No JSON object could 4 be decoded 4.5. 要注意JSON字符串的编码 相关旧帖 【经验记录】Python中json.loads的时候出错->要注意要解码的Json字符的编码 5 1 http://www.crifan.com/add_comments_for_json http://www.crifan.com/python_json_loads_valueerror_expecting_property_name_line_1_column_1_char_1 http://www.crifan.com/use_python_json_loads_parse_string_contain_newline_will_fail_error 4 http://www.crifan.com/python_json_loads_valueerror_no_json_object_could_be_decoded 5 http://www.crifan.com/notation_about_use_python_json_loads 2 3 5