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


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


          網站導航:
           
          主站蜘蛛池模板: 綦江县| 常熟市| 法库县| 新营市| 宾川县| 南漳县| 曲周县| 磴口县| 二连浩特市| 罗定市| 三门县| 交口县| 个旧市| 宁波市| 涞水县| 五莲县| 且末县| 平潭县| 宁蒗| 武城县| 林周县| 乾安县| 湛江市| 温泉县| 宜兰县| 大安市| 巴彦县| 黔江区| 惠来县| 灵武市| 洛川县| 阿合奇县| 准格尔旗| 盖州市| 禄劝| 乌鲁木齐县| 黄大仙区| 文安县| 温宿县| 社旗县| 收藏|