Java 将JSON插入SQLite(GSON+;截取)

Java 将JSON插入SQLite(GSON+;截取),java,android,json,gson,Java,Android,Json,Gson,来自此主题: 从截击的反应开始: public void onResponse(String response) { OverallModel itemList; itemList = new Gson().fromJson(response,OverallModel[].class); helper.insertData(itemList); 这是我的整体模型: public class OverallModel { p

来自此主题:

从截击的反应开始:

        public void onResponse(String response) {
        OverallModel itemList;
        itemList = new Gson().fromJson(response,OverallModel[].class);
        helper.insertData(itemList);
这是我的整体模型:

public class OverallModel {
    public int id;
    public String beschreibung;
    public String datum;
    public String image_link;
    public String location;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getBeschreibung() {
        return beschreibung;
    }

    public void setBeschreibung(String beschreibung) {
        this.beschreibung = beschreibung;
    }

... other getters and setters here
使用这样的JSON:

[
  {
    "id": "1",
    "name": "Event One",
    "beschreibung": "Description here - Skip quot'e's'?",
    "date": "14.01.2017",
    "image_link": "http://google.com/icon.png"
    "location":"location goes here"
  },
  {
    "id": "2",
    "name": "Event Two",
    "beschreibung": "Description here - Skip quot'e's'?",
    "date": "16.01.2017",
    "image_link": "http://google.com/icon.png"
    "location":"location goes here"
  },
  .
  .
  .
]
现在,我需要一个助手方法将数据放入SQLite DB,没有GSON,我使用以下代码:

JSONArray events = response.getJSONArray("events");
for (int h = 0; h < events.length(); h++) {
String jr_date = c.getString("datum");
String jr_imgurl = c.getString("image_link");
.
.
String SQLiteDataBaseQuery
                                = "INSERT INTO overall_table (id,des,name,date,imgurl,fburl,fbid,entry,open,closed) VALUES('"+id+"', '"+jr_descr+"', '"+jr_name+"', '"+jr_date+"', '"+jr_imgurl+"', '"+jr_fburl+"', '"+jr_fbid+"', '8.0' , '22:00', '3:30');";
                        sqLiteDatabase.execSQL(SQLiteDataBaseQuery);
如何为我的GSON创建正确的帮助器类以将反序列化数据放入我的表/DB?

使用ORM数据库


您可以轻松高效地插入模型列表。

我从未听说过,谢谢您的输入。但是我的其余部分使用我正在解析的sqlite表,我是否可以只使用这个库来解析JSON,而不使用“访问解析表”代码?你能为我的JSON做个例子吗?
public void onCreate(SQLiteDatabase database) {
String CREATE_TABLE="CREATE TABLE IF NOT EXISTS " +TAB_NAME+" ("+table_id+" INTEGER PRIMARY KEY, "
+table_desc+" VARCHAR, "
+ table_name+ " VARCHAR, "
+ table_date+" VARCHAR, "
.
.
+ table_open+" VARCHAR,"
+ table_closed+" VARCHAR)";
database.execSQL(CREATE_TABLE);
}