`
eggbucket1
  • 浏览: 78381 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
文章分类
社区版块
存档分类
最新评论

What is JSON and Its usage

阅读更多

JSON的起源
XML数据传输格式外,还有一种相对来说使用很多的数据传输格式
甚至某些场合使用的比XML还要多,这种数据传输格式就是所谓的JSON
JSON(JavaScript Object Notation)的官网是http://www.json.org
他的创建者是雅虎的主架构师,也是YUI(Yahoo User Interface)框架的架构师
他就是道格拉斯(Douglas Crockford),他是在雅虎工作期间发明的JSON数据传输格式

JSON的好处
JSON相对于XML来说,它读起来更加简单方便
JSON更加简洁,传输量更加少。因为它使用的字符明显少很多
对于大量数据的情况来说,使用XML显然比JSON要传输更多的数据
所以使用JSON可以在一定程度上降低网络负载
若使用JSON仅表示一个对象的话,直接{id: 1, name: zhangsan}即可
JSON的本质非常简单,它的基本想法就是通过name-value的形式描述信息
类似于Java集合的Map,下面分别举例通过XML和JSON描述2个用户的信息
[{id: 1, name: zhangsan}, {id: 2, name: lisi}]
<users>
<user>
<id>1</id>
<name>zhangsan</name>
</user>
<user>
<id>2</id>
<name>lisi</name>
</user>
</users>

下面是JSON与Struts2集成的演示其中前台页面使用了JQuery实现异步请求

首先是web.xml文件

然后是jsonTest.jsp页面

接着是struts.xml文件

然后是POJO类

最后是核心的GetJsonAction类

分享到:
评论

相关推荐

    Mastering.Text.Mining.with.R.epub

    cleanse, and process text using the R language and will equip you with the tools and the associated knowledge about different tagging, chunking, and entailment approaches and their usage in natural ...

    Mastering Text Mining with R [2016]

    cleanse, and process text using the R language and will equip you with the tools and the associated knowledge about different tagging, chunking, and entailment approaches and their usage in natural ...

    Beginning PHP 5.3

    - **PEAR Overview:** Explanation of what PEAR (PHP Extension and Application Repository) is and how it works. - **Installing PEAR:** Instructions on installing PEAR and its components. - **PEAR ...

    python3.6.5参考手册 chm

    Performance and resource usage PEP 397: Python Launcher for Windows PEP 3151: Reworking the OS and IO exception hierarchy PEP 380: Syntax for Delegating to a Subgenerator PEP 409: Suppressing ...

    用友自动化测试面试题

    ### 用友自动化测试面试题知识点解析 #### 1. 英文测试用例和测试计划的编写(用英语回答) - **Test Case Writing in English**: ... - **JSON/YAML**: Often used for configuration files and structured data.

    google api php client

    The method used is a matter of preference, but *it will be very difficult to use this library without first understanding the JSON syntax for the API*, so it is recommended to look at the [APIs ...

    The way to go

    2.6 What is installed on your machine? .........................................................................26 2.7 The Go runtime.....................................................................

    [Go语言入门(含源码)] The Way to Go (with source code)

    2.6 What is installed on your machine? .........................................................................26 2.7 The Go runtime.....................................................................

Global site tag (gtag.js) - Google Analytics