1、

  资料网址:

    http://blog.csdn.net/vincent_czz/article/details/7333977

    http://blog.csdn.net/huangwuyi/article/details/5412500

  下载网址:https://sourceforge.net/projects/json-lib/files/

  在线API:http://json-lib.sourceforge.NET/apidocs/jdk15/index.html

2、

  异常处理:http://www.xuebuyuan.com/2158801.html

  2.1、异常:

    在“JSONObject.fromObject(...)”处报错:“Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException”

  2.2、处理:

    项目中导入了 json-lib 包,但是在运行如下代码的时候还是出现了如下错误,究其原因是因为缺包,缺了如下5个包:

      commons-beanutils-1.8.3
      commons-lang-2.6 (注:导入最新的 3.1 版本会继续报上面的错误)
      commons-collections-3.2.1
      commons-logging-1.1.1
      ezmorph-1.0.6

  2.3、我现在使用的相关包分别为:(它们 都是从各自的官网上下载下来的)

    (1)、json-lib-2.4-jdk15.jar
    (2)、commons-beanutils-1.8.3.jar
    (3)、commons-collections-3.2.2.jar
    (4)、commons-lang-2.6.jar
    (5)、commons-logging-1.2.jar
    (6)、ezmorph-1.0.6.jar

3、ZC 测试代码

package test;

import java.util.Iterator;
import net.sf.json.*; public class Ttest03
{
public static void main(String[] args)
{
String jsonString = "{\"FLAG\":\"flag\",\"MESSAGE\":\"SUCCESS\",\"name\":[{\"name\":\"jack\"},{\"name\":\"lucy\"}]}";
try
{
JSONObject result = JSONObject.fromObject(jsonString);//转换为JSONObject
JSONArray nameList = result.getJSONArray("name");//获取JSONArray
int iSize = nameList.size();
System.out.println("iSize : "+iSize); String strName01 = "";
for(int i = 0; i < iSize; i++)//遍历JSONArray
{
JSONObject oj = nameList.getJSONObject(i);
strName01 = oj.getString("name");
System.out.println("["+Integer.toString(i)+"] : name : "+strName01);
}
Iterator<?> itKeys = result.keys();
String aa2 = "";
String bb2 = null;
while(itKeys.hasNext())//遍历JSONObject
{
bb2 = (String) itKeys.next().toString();
aa2 = result.getString(bb2);
System.out.println(bb2+" -- "+aa2);
}
//} catch (JSONException e) {
} catch (Exception e) {
throw new RuntimeException(e);
}
} }

4、

5、

最新文章

  1. Webstorm 下的Angular2.0开发之路
  2. 《统计推断(Statistical Inference)》读书笔记——第1章 概率论
  3. 移植u-boot.2012.04.01
  4. Hibernate4搭建Log4J日志管理(附Log4j.properties配置详解)
  5. Python Tutorial学习(十一)-- Brief Tour of the Standard Library – Part II
  6. 关于xml作为模板的配置服务系统开发
  7. linux下清理系统垃圾
  8. ArcSDE for Oracle表空间管理——暂时(TEMP)表空间
  9. PHP中的数组方法及访问方法总结
  10. Swift语言指南(二)--语言基础之注释和分号
  11. Java笔记:内部类
  12. C语言中数组转化为字符串的方法
  13. 中国四大骨干网与十大ISP服务商
  14. MapReduce实现ReduceSideJoin操作
  15. java知识点3
  16. 解决jqueryeasyUI dialog 弹出窗体超出浏览器,导致不能关闭的bug
  17. POJ2431 Expedition 贪心
  18. Jquery easyui 重置按钮,easyui 清空表单,Jquery easyui 重置表单
  19. laravel5.3的多用户登录,经过验证laravel5.4可用【转帖】
  20. scala 学习笔记五 foreach, map, reduce

热门文章

  1. 巨蟒python全栈开发-第15天 装饰器
  2. c++用vector创建二维数组
  3. 搞懂head 和 tail 命令
  4. 转!!DNS域名解析使用的是TCP协议还是UDP协议?
  5. 微信读书App来了 小伙伴们快去占榜吧
  6. Python基础-面向对象2
  7. Centos7管理selinux及使用firewalld管理防火墙
  8. Java中String.valueOf、toString、(String)的区别
  9. IOS中快速集成短信SDK验证开发(SMSSDK),IOS开发中如何设置手机验证码
  10. pycharm修改配置