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 閱讀(3820) 評論(0)  編輯  收藏


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


          網站導航:
           
          主站蜘蛛池模板: 运城市| 绥宁县| 安顺市| 嘉鱼县| 兴国县| 左云县| 鱼台县| 尼木县| 澄迈县| 永寿县| 金溪县| 宝清县| 敦煌市| 尼木县| 青阳县| 藁城市| 阳新县| 翼城县| 永川市| 云和县| 察雅县| 三明市| 南江县| 库尔勒市| 苍山县| 萨迦县| 临夏县| 大埔区| 岢岚县| 桦川县| 云霄县| 汪清县| 古丈县| 广南县| 富源县| 宜春市| 七台河市| 巴里| 娄烦县| 马尔康县| 汝城县|