关于Gson的一般用法及常见问题的解决方案

本文介绍Gson,一个由Google开发的用于Java对象与JSON相互转换的工具包。它轻巧简便,易于使用,拥有完备的文档支持,并且是开源的。在B/S网络编程开发中,Gson提供了解析或生成JSON的功能,简化了与前端页面的交互任务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.cnblogs.com/lang86987182/articles/2179843.html


介绍:

  Gson是google开发的一个Java对象与JSON相互转化的工具包.它轻巧简便,易于使用,有很完备的文档可供查询,并且是开源的。

来自以下网址 
引用


引用
在B/S网络编程开发中,后台利用Java解析或者生成JSON,与前端页面的交互的任务可以利用一些开源的小jar包解决,当然自己写一些简单的也是可行的,最近发现了GSON这个Google开发的,不是必须使用annotation,很好用,下面简单记录下用法。


引用
Gson is a Java library that can be used to convert Java Objects into its JSON representation. It can also be used to convert a JSON string to an equivalent Java object. Gson can work with arbitrary Java objects including pre-existing objects that you do not have source-code of. 

There are a few open-source projects that can convert Java objects to JSON. However, most of them require that you place Java annotations in your classes something that you can not do if you do not have access to the source-code. Most also do not fully support the use of Java Generics. Gson considers both of these as very important design goals.


GSON:  http://code.google.com/p/google-gson/  
GSON API:  http://google-gson.googlecode.com/svn/tags/1.3/docs/javadocs/index.html  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值