Vikings

          Json-lib 的JsonArray比Json-rpc的JsonArray用起來爽

          1.json-rpc里的jsonArray一般要這么拿數據,再包裝
          JSONArray cgs = new JSONArray();
            Collection<RecruitmentVO> categories = informationDAO.getAllInformation();
            for(RecruitmentVO c : categories){   
             JSONObject o = new JSONObject();
             o.put("id", c.getId());
             o.put("title", c.getCompanyName());
             cgs.put(o);
            }
            return cgs.toString();

          2.用了json-lib的JsonArray,一切很方便
             List<AjSaryxx> list = saryService.queryDBSaryxxRseultList(zjxx,pageInfo);
             JSONArray jsonArray = JSONArray.fromObject(list);        

          接著List里有什么, JSONArray就轉為相對應的Json

           

          JSON

           

          Java

          string

          <=>

          java.lang.String, java.lang.Character, char

          number

          <=>

          java.lang.Number, byte, short, int, long, float, double

          true|false

          <=>

          java.lang.Boolean, boolean

          null

          <=>

          null

          function

          <=>

          net.sf.json.JSONFunction

          array

          <=>

          net.sf.json.JSONArray (object, string, number, boolean, function)

          object

          <=>

          net.sf.json.JSONObject


          工具幫你完成轉換.
          稍為不是很方便的是. json-lib-1.5.jar需要以下jar. 一個一個找對版本才能用. 網站就沒有一個打包好的..

          • jakarta commons-lang 2.3
          • jakarta commons-beanutils 1.7.0
          • jakarta commons-collections 3.2
          • jakarta commons-logging 1.1
          • ezmorph 1.0.3

          posted on 2007-11-01 22:28 Vikings 閱讀(3825) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 阳原县| 新竹市| 新化县| 定襄县| 灵丘县| 邛崃市| 调兵山市| 腾冲县| 大石桥市| 隆昌县| 株洲市| 磴口县| 安泽县| 昭苏县| 通江县| 盐源县| 蓝山县| 临高县| 调兵山市| 墨玉县| 石门县| 义马市| 上杭县| 天镇县| 灵川县| 桦甸市| 双柏县| 定远县| 浪卡子县| 项城市| 环江| 芜湖县| 龙里县| 策勒县| 山阴县| 高碑店市| 辽阳县| 五原县| 泰来县| 乌审旗| 时尚|