java:net.sf.json.JSON…… 常見問題

1、時間類型轉換異常

JSONArray json = JSONArray.fromObject(str);
JSONUtils.getMorpherRegistry().registerMorpher(new DateMorpher(new String[]{"yyyy-MM-dd HH:mm:ss"}), true);
lists = (List<Res>)JSONArray.toCollection(json, Res.class);

2、轉換編碼問題

str = URLDecoder.decode(str, "UTF-8");
JSONObject json = JSONObject.fromObject(str);
Map res = (Map)JSONObject.toBean(json, Map.class);

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章