-1

I try to set this type of json response in my code i try to set questions in one text view and set answer to other text view

{
"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
                }
            ],

}

How to pass this type of json response in android like question show in one textview and answer shows in other textview?

Darshi Patel
  • 294
  • 3
  • 11

1 Answers1

0

First you should add dependency to your app gradle file then you will be able to serialize your json object using @Serialize annotation in your java object class. After that you can place your question and answer to appropriate TextView

Asset Bekbossynov
  • 1,633
  • 3
  • 13
  • 25