// 引入相应的包
//json-lib-2.2-jdk15.jar
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
1. //把java 对象列表转换为json对象数组,并转为字符串
JSONArray array = JSONArray.fromObject(userlist);
String jsonstr = array.toString();
2.//把java对象转换成json对象,并转化为字符串
JSONObject object = JSONObject.fromObject(invite);
Log4jInit.ysulogger.debug(object.toString());
3.//把JSON字符串转换为JAVA 对象数组
String personstr = getRequest().getParameter("persons");
JSONArray json = JSONArray.fromObject(personstr);
List<InvoidPerson> persons = (List<InvoidPerson>)JSONArray.toCollection(json, nvoidPerson.class);
4.//把JSON字符串转换为JAVA 对象
str = "{\"lendperson\":\"李四\",\"lendcompany\":\"有限公司\",\"checkperson\":\"李四\",
\"lenddate\":\"2010-07-19T00:00:00\",\"lendcounts\":4,\"
passports\":[{\"passportid\":\"d\",\"name\":\"李豫川\",\"passporttype\":\"K\"},
{\"passportid\":\"K9051\",\"name\":\"李平\",\"passporttype\":\"K\"},
{\"passportid\":\"K90517\",\"name\":\"袁寒梅\",\"passporttype\":\"K\"},
{\"passportid\":\"K905199\",\"name\":\"贺明\",\"passporttype\":\"K\"}]}";
JSONObject jsonobject = JSONObject.fromObject(str);
PassportLendsEntity passportlends = null;
try {
//获取一个json数组
JSONArray array = jsonobject.getJSONArray("passports");
//将json数组 转换成 List<PassPortForLendsEntity>泛型
List<PassPortForLendsEntity> list = new ArrayList<PassPortForLendsEntity>();
for (int i = 0; i < array.size(); i++) {
JSONObject object = (JSONObject)array.get(i);
PassPortForLendsEntity passport = (PassPortForLendsEntity)JSONObject.toBean(object,
PassPortForLendsEntity.class);
if(passport != null){
list.add(passport);
}
}
//转换PassportLendsEntity 实体类
passportlends = (PassportLendsEntity)JSONObject.toBean(jsonobject, PassportLendsEntity.class);
没有合适的资源?快使用搜索试试~ 我知道了~
源代码和数据库皆上传。此项目为SSH框架的服务器端与Android的客户端通过Json进行数据交互,适合新手,简单易学
共139个文件
jar:51个
class:18个
xml:14个
需积分: 9 15 下载量 24 浏览量
2018-11-12
22:36:55
上传
评论 1
收藏 14.25MB RAR 举报
温馨提示
源代码和数据库皆上传。此项目为SSH框架的服务器端与Android的客户端通过Json进行数据交互,适合新手,简单易学
资源推荐
资源详情
资源评论
收起资源包目录
源代码和数据库皆上传。此项目为SSH框架的服务器端与Android的客户端通过Json进行数据交互,适合新手,简单易学 (139个子文件)
resources.ap_ 11KB
NewsApp.apk 90KB
proguard.cfg 1KB
NewsActivity$NewsAdapter.class 3KB
HttpUtil.class 2KB
NewsAction.class 2KB
NewsActivity.class 2KB
NewsService.class 2KB
News.class 2KB
News.class 2KB
BaseDao.class 1KB
NewsService.class 800B
BaseAction.class 764B
NewsService$1.class 675B
R.class 552B
R$id.class 538B
NewsDao.class 529B
R$layout.class 445B
R$string.class 436B
R$drawable.class 416B
R$attr.class 349B
.classpath 5KB
.classpath 422B
org.eclipse.wst.common.component 450B
org.eclipse.wst.jsdt.ui.superType.container 49B
classes.dex 177KB
hibernate3.jar 2.31MB
com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar 1.57MB
mysql-connector-java-5.1.12.jar 716KB
org.springframework.context-3.0.1.RELEASE-A.jar 642KB
javassist-3.9.0.GA.jar 583KB
commons-collections-3.1.jar 546KB
org.springframework.beans-3.0.1.RELEASE-A.jar 535KB
org.springframework.web.struts-3.0.1.RELEASE-A.jar 524KB
spring-beans-2.5.6.jar 477KB
spring-context-2.5.6.jar 466KB
antlr-2.7.6.jar 433KB
org.springframework.web.servlet-3.0.1.RELEASE-A.jar 389KB
com.springsource.org.apache.log4j-1.2.15.jar 387KB
org.springframework.jdbc-3.0.1.RELEASE-A.jar 369KB
log4j-1.2.14.jar 359KB
org.springframework.web-3.0.1.RELEASE-A.jar 352KB
org.springframework.core-3.0.1.RELEASE-A.jar 347KB
org.springframework.orm-3.0.1.RELEASE-A.jar 324KB
com.springsource.net.sf.cglib-2.2.0.jar 319KB
org.springframework.aop-3.0.1.RELEASE-A.jar 313KB
dom4j-1.6.1.jar 307KB
com.springsource.org.apache.commons.httpclient-3.1.0.jar 301KB
spring-core-2.5.6.jar 279KB
hibernate-annotations.jar 273KB
cglib-2.2.jar 272KB
com.springsource.org.codehaus.jackson.mapper-1.0.0.jar 264KB
org.springframework.transaction-3.0.1.RELEASE-A.jar 223KB
gson-2.3.1.jar 206KB
ehcache-1.2.3.jar 203KB
spring-web-2.5.6.jar 190KB
org.springframework.web.portlet-3.0.1.RELEASE-A.jar 169KB
org.springframework.expression-3.0.1.RELEASE-A.jar 152KB
json-lib-2.1.jar 122KB
hibernate-entitymanager.jar 116KB
ezmorph-1.0.6.jar 84KB
persistence.jar 69KB
hibernate-commons-annotations.jar 65KB
hibernate-validator.jar 61KB
com.springsource.org.apache.commons.logging-1.1.1.jar 60KB
org.springframework.oxm-3.0.1.RELEASE-A.jar 56KB
com.springsource.org.apache.commons.fileupload-1.2.0.jar 53KB
org.springframework.asm-3.0.1.RELEASE-A.jar 52KB
ejb3-persistence.jar 49KB
org.springframework.aspects-3.0.1.RELEASE-A.jar 29KB
slf4j-api-1.5.8.jar 23KB
struts2-spring-plugin-2.1.8.1.jar 16KB
jta-1.1.jar 13KB
slf4j-log4j12-1.5.8.jar 9KB
org.springframework.instrument.tomcat-3.0.1.RELEASE-A.jar 5KB
com.springsource.org.aopalliance-1.0.0.jar 5KB
org.springframework.instrument-3.0.1.RELEASE-A.jar 2KB
NewsActivity.java 2KB
HttpUtil.java 2KB
News.java 1KB
News.java 1KB
NewsAction.java 1KB
R.java 1KB
BaseDao.java 915B
NewsService.java 850B
BaseAction.java 687B
NewsService.java 429B
NewsDao.java 230B
news4.jpg 54KB
news4.jpg 54KB
news6.jpg 15KB
news6.jpg 15KB
news2.jpg 9KB
news2.jpg 9KB
news3.jpg 5KB
news3.jpg 5KB
news1.jpg 5KB
news1.jpg 5KB
news5.jpg 3KB
news5.jpg 3KB
共 139 条
- 1
- 2
资源评论
小月施主
- 粉丝: 185
- 资源: 662
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功