Vikings

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

          1.json-rpc里的jsonArray一般要這么拿數(shù)據(jù),再包裝
          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就轉(zhuǎn)為相對應(yīng)的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


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

          • 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)  編輯  收藏


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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 罗山县| 凤阳县| 龙口市| 肃北| 微博| 元朗区| 仁化县| 佛学| 丹江口市| 松江区| 武穴市| 无极县| 镇原县| 寻甸| 曲周县| 读书| 丹棱县| 综艺| 崇礼县| 甘谷县| 共和县| 阿勒泰市| 兴安盟| 霍州市| 昌黎县| 兴宁市| 裕民县| 苏尼特右旗| 沂南县| 永清县| 凭祥市| 新余市| 西乌珠穆沁旗| 常宁市| 阿图什市| 澄迈县| 柳江县| 莫力| 漠河县| 新乡县| 疏附县|