set sample
... import org.json.JSONObject; ... String others = rs.getString("others"); // ex: {"thumbnail_sec":"106","rotate":"90"} String result[] = null; try { JSONObject jsonObj = new JSONObject(others); result[0] = String.valueOf(jsonObj.get("thumbnail_sec")); result[1] = String.valueOf(jsonObj.get("rotate")); } catch (JSONException e) { // rotate 沒值也會進這裡 //encObj.getLogHelper().log("JSONException:" + e); } return result[]; // 收到後要再處理 null 與 "" 的部份 ...
get sample
... import org.json.JSONObject; ... EncodeObject obj = (EncodeObject)obj.clone(); JSONObject json = new JSONObject(obj); // json.toString() 寫入 field 中 ...
ref : http://www.pocketdigi.com/20110912/470.html
沒有留言:
張貼留言