我有一个表示为JSON字符串的对象数组,它将来自API服务器。假设我们有一些属于每个类别的电影类别和实际电影:
[
{
"id": "1",
"name": "Action",
"movies": [
{
"id": "1",
"name": "Movie 1",
"description": "Movie 1 Description",
"other": "Other..."
},
{
"id": "2",
"name": "Movie 2",
"description": "Movie 2 Description",
"other": "Other..."
}
]
},
{
"id": "2",
"name": "Drama",
"movies": [
{
"id": "3",
"name": "Movie 3",
"description": "Movie 3 Description",
"other": "Other..."
},
{
"id": "4",
"name": "Movie 4",
"description": "Movie 4 Description",
"other": "Other..."
}
]
}
]
我的Android应用程序的用户需要能够浏览类别/电影。
关于代码性能和最佳内存使用情况,下列哪种情况更好?
假设会有很多频道和类别
1.解析JSON字符串一次,为每个类别创建Category和Movie对象的ArrayLists,稍后我将用它们填充列表。
2.使用get_total_channels,get_channel,get_category等少数方法创建一个Parser,它将始终解析JSON字符串的内容,以返回适当的数据来填充列表。
3.还有其他建议吗?