/** 

      * 将json数字字符串转化为相应对象集合 

      * @param jsonArray json数组字符串 

      * @param clazz     Class类型 

      * @return 

      * @throws Exception 

      */ 

     public static<T> List<T> parseJSONArray(String jsonArray,Class<T> clazz) throws Exception{ 

         List<T> list = new ArrayList<T>(); 

         String datas = jsonArray.substring(1, jsonArray.length()-1); 

         String[] sps = datas.split("},"); 

         for (String sp : sps) { 

             if(sp.indexOf("}")!=sp.length()-1){ 

                 sp=sp+"}"; 

             } 

             T obj = parseJSON(sp, clazz); 

             list.add(obj); 

         } 

         return list; 

     } 

     /** 

      * 将单个json 对象转化为java对象 

      * @param json 

      * @param clazz 

      * @return 

      * @throws Exception 

      */ 

     public static <T> T parseJSON(String json,Class<T> clazz) throws Exception{ 

         String data=json.substring(1, json.length()-1); 

         String[] sps = data.split(","); 

         T newInstance = clazz.newInstance(); 

         BeanInfo beanInfo = Introspector.getBeanInfo(clazz); 

         PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); 

         for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { 

             for (String sp : sps) { 

                 String[] kv = sp.split(":"); 

                 if(propertyDescriptor.getName().equals(kv[0])){ 

                 

                     Method wMethod = propertyDescriptor.getWriteMethod(); 

                     Class pt=propertyDescriptor.getPropertyType(); 

                     if(!pt.getName().equals("java.lang.String")){ 

                         wMethod.invoke(newInstance,parseType(kv[1],pt )); 

                     }else{ 

                         wMethod.invoke(newInstance, kv[1]); 

                     } 

                 } 

             } 

         } 

         return newInstance; 

     } 

     /** 

      * 将字符串转为基本包装类型 

      * @param value 

      * @param t 

      * @return 

      * @throws Exception 

      */ 

     public static <T> T parseType(String value,Class<T> t) throws Exception{ 

         String type=t.getSimpleName(); 

         Constructor<T> constructor = t.getConstructor(String.class); 

         return (T) constructor.newInstance(value); 

     }