json(javascript object Notation)是一种轻量级的数据交换格式,易于人阅读和编写。同时也易于机器解析和生成。它基于javascript programming language,json采用彻底独立于语言的文本格式,可是也使用了相似于C语言家族的习惯,这些特性使json成为理想的数据交换语言javascript
首先json是字符串java
字符串是用来传递信息的,json字符串实际上就是一种规定了格式的字符串python
经过这种格式,咱们能够在不一样的编程语言之间互相传递信息,好比咱们能够把javascrupt对象转换成json传递给java,这样java能够反解析出java语言自身表明的对象,同理,咱们能够把java对象转成json,经过解析json,python语言能够把json转成自身的字典或list,json统一了交流的格式,使得信息能够在不一样的语言间顺畅传递编程
好比,咱们能够把json字符串转成python语言的dictjson
#coding: utf-8 import json json_str = """ { "id" : 90, "name" : "python", "url" : "http://www.v2ex.com/go/python", "title" : "Python", "title_alternative" : "Python", "topics" : 7646, "stars" : 4862, "header" : "这里讨论各类 Python 语言编程话题,也包括 Django,Tornado 等框架的讨论。这里是一个可以帮助你解决实际问题的地方。", "footer" : null, "created" : 1278683336, "avatar_mini" : "//v2ex.assets.uxengine.net/navatar/8613/985e/90_mini.png?m=1504080972", "avatar_normal" : "//v2ex.assets.uxengine.net/navatar/8613/985e/90_normal.png?m=1504080972", "avatar_large" : "//v2ex.assets.uxengine.net/navatar/8613/985e/90_large.png?m=1504080972" } """ res = json.loads(json_str) print(res['id']) # 90 print(res['name']) # python print(res['url']) # http://www.v2ex.com/go/python