将对象的 ArrayList 转换为 JSON 以保存到 SQLITE [英] Converting an ArrayList of Objects to JSON to be saved into SQLITE
问题描述
我想将对象的 ArrayList (ArrayList) 存储到 SQLITE 数据库中.我已经读到这是可以做到的.我相信通过将 ArrayList 转换为 JSON,然后将其保存到 SQLITE 表中的 String 字段
I want to store an ArrayList of Objects (ArrayList) into a SQLITE database. I have read that this can be done. I believe that by converting the ArrayList to JSON and then save that to a String field in a SQLITE Table
有人可以指出我如何进行这种转换以及之后如何将其转换回 ArrayList 的正确方向.
Can someone point me in the right direction on how to do this conversion and how to convert it back to ArrayList afterwards.
感谢您的时间
推荐答案
这可以帮助您:
http://www.kodejava.org/examples/588.html
这个例子展示了如何将 Collection (List/ArrayList)
转换为 JSON
而不是你可以在 Sqlite 中存储你的
数据库.JSON
字符串
This example shows how to convert Collection (List/ArrayList)
to JSON
than you can store your JSON
string in Sqlite
database.
它还展示了如何从 JSON
字符串中取回 ArrayList
.
It is also showing how to get ArrayList
back from JSON
string.
这篇关于将对象的 ArrayList 转换为 JSON 以保存到 SQLITE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!