java 解析josn数组
2016-07-06 15:07
393 查看
java解析json数组:需要添加一个jar包,自己搜索即可
import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public static void main(String[] args) throws JSONException { String sJson = "[{'gwcxxid':'1','spsl':'2'},{'gwcxxid':'1','spsl':'2'},{'gwcxxid':'3','spsl':'4'}]" ; JSONArray jsonArray = new JSONArray(sJson); int iSize = jsonArray.length(); System.out.println( "Size:" + iSize); for ( int i = 0 ; i < iSize; i++) { JSONObject jsonObj = jsonArray.getJSONObject(i); System.out.println( "[" + i + "]gwcxxid=" + jsonObj.get( "gwcxxid" )); System.out.println( "[" + i + "]spsl=" + jsonObj.get( "spsl" )); System.out.println(); } } |
相关文章推荐
- 多线程设计模式——Guarded Suspension(保护性暂挂模式)
- 关于springmvc的拦截器
- java链表之--单向链表的增删改查
- java-socket编程_ 1.socket入门
- 利用maven/eclipse搭建ssm(spring+spring mvc+mybatis)
- 【Spring】Spring源码分析--整体架构
- java集合概述
- jdk环境变量的配置,Path路径的查看
- Hibernate整合Spring后,如何使用SchemaExport生成数据库表
- Java对象的创建
- Math对象(javasript)
- 深入分析 Java I/O 的工作机制
- Java 理论与实践: 正确使用 Volatile 变量
- java注解
- Java 高并发缓存与Guava Cache
- maven基础知识——包管理
- Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)
- java删除递归文件夹及文件夹下文件
- SpringMVC和Struts2的区别
- 导入自己的jar包到maven依赖库中