我尝试在代码中设置这种json响应类型,我尝试在一个文本视图中设置问题并为其他文本视图设置答案
{
"subcategory": {
"id": 1,
"category_id": 1,
"name": "MLB - Major League Baseball",
"upload": null,
"total_points": [
{
"id": 1,
"user_id": 3,
"subcategory_id": 1,
"total": 10
}
],
"questions": [
{
"id": 1,
"subcategory_id": 1,
"question": "This is a test question.",
"link": "",
"banner_link": "",
"answers": [
{
"id": 1,
"question_id": 1,
"answer": "Answer 1",
"point": 10
},
{
"id": 2,
"question_id": 1,
"answer": "Answer 2",
"point": 20
},
{
"id": 3,
"question_id": 1,
"answer": "Answer 3",
"point": 30
},
{
"id": 4,
"question_id": 1,
"answer": "Answer 4",
"point": 40
}
],
}
如何在android中传递这种json响应,例如在一个textview中传递问题显示而在另一个textview中传递答案显示?
答案 0 :(得分:0)
首先,您应该将dependency添加到应用程序gradle
文件中,然后才能使用Java对象类中的@Serialize
批注来序列化json对象。之后,您可以提出问题并回答适当的TextView