What is GSON and Its usage
来源:互联网 发布:zookeeper 集群 端口 编辑:程序博客网 时间:2024/04/29 16:45
完整版见https://jadyer.github.io/2010/12/10/json-js/
Gson的用途
在Struts2中使用JSON时,需要将序列化的属性定义在相应Action中
而我们也可以采取程序的方式,进行属性的组装,然后再生成JSON
这样的工具有很多,这里介绍一个比较强大的工具Gson
它可以直接通过Gson类的toJson()方法将Java对象转化成JSON表达式
Gson是JSON的一个Java开发包,它是由Google开发出来的
它的官方网站是http://code.google.com/p/google-gson
下面是JSON与Struts2集成的演示,其中前台页面使用了JQuery实现异步请求
首先是web.xml文件
然后是gsonTest.jsp页面
接着是struts.xml文件
然后是两个POJO类
最后是核心的GetGsonAction类
- What is GSON and Its usage
- What is JSON and Its usage
- What Is /dev/shm And Its Practical Usage
- RScheduler and its Usage
- auto_ptr and its usage
- What's NLS_LANG and usage
- what does router do and its purpose?
- What is the best free memory leak detector for a C/C++ program and its plug-in DLLs
- What is the best free memory leak detector for a C/C++ program and its plug-in DLLs
- Active Lookup Transformation – Learn its usage and configuration steps
- What is aliasing and what causes it?
- what is BI and OLAP?
- What is CEO and others ?
- What is globalization and localization?
- What is heap and stack?
- What is Called and When
- what is BI and OLAP
- what is BI and OLAP
- 十八个重要的算法
- Flex元素布局规则总结
- 一不小心陷入失落
- java中获取路径的几种方法
- Oracle数据库删除两表中相同数据的方法
- What is GSON and Its usage
- jQuery中的ajax服务端返回方式(转)
- 从N-皇后问题看回溯法
- 射影几何入门(连载一)- 1-1对应.
- POJ 题目分类
- sql语句字符串处理大全
- 通过LDAP验证
- 如何卸载软件
- directfb png透明色问题