package com.novelbook.android.utils; import com.novelbook.android.db.Novel; import org.json.JSONException; import org.json.JSONObject; public class GsonUtil { public static Novel getNovel(String json){ Novel nv = new Novel(); try { JSONObject jsonObject = new JSONObject(json); nv.setNovelId(jsonObject.getString("novelId")); nv.setLastUpateTime(jsonObject.getLong("lastUpateTime")); nv.setAuthor(jsonObject.getString("author")); nv.setName(jsonObject.getString("name")); nv.setCover(jsonObject.getString("cover")); nv.setNovelType(jsonObject.getString("novelType")); nv.setNovelType2(jsonObject.getString("novelType2")); nv.setLastestChapterName(jsonObject.getString("lastestChapterName")); return nv; } catch (JSONException e) { e.printStackTrace(); } return nv; } }