执行:
JSONArray array = JSONArray.fromObject(list);list 里面是map集合  map里面的数据是map1.put("id","1");
map1.put("pId","001");
map1.put("name","01");就会报以下错误:
net.sf.json.JSONException: java.lang.reflect.InvocationTargetException
http://yoyang.iteye.com/blog/651895 方法已经试过 无用........

解决方案 »

  1.   

    这个异常,一般是由于调用Mathod类的invoke()方法引发的,
    细看你的描述,确实有些不对劲,如果你这样 
    String list = "[{\"id\":\"1\",\"pId\":\"001\",\"name\":\"01\"},{\"id\":\"2\",\"pId\":\"002\",\"name\":\"02\"}]";
    JSONArray array = JSONArray.fromObject(list);就不会报这个错了,不妨试一下!
      

  2.   

    InvocationTargetException是指在反射执行一个方法时出现异常,要查看这个异常的详细信息需要调用异常对象的getTargetException()方法获取被执行方法中的异常对象,然后再打印异常
    如:e.getTargetException().printStackTrace();
    看到了这个异常的信息,你就能知道哪个方法的什么地方出现了问题了
      

  3.   

    commons-beanutils-1.7.0.jar   commons-lang-2.1.jar  ezmorph-1.0.2.jar  json-lib-1.1-jdk15.jar  我这里测试 你的例子了没有问题 原因可能是你没有导入ezmorph-1.0.2.jar 包
    public static void main(String[] args){

    List list =new ArrayList();
    Object obj="";
    Map map1=new HashMap();
    map1.put("id","1");
    map1.put("pId","001");
    map1.put("name","01"); JSONArray array = JSONArray.fromObject(list);
    }