首页 > 解决方案 > 修改地图

问题描述

需要List<Map<String, dynamic>> httpResponse =[];将获取的 List 修改为新的 List。List 是通过 Http 请求获取的,需要添加一个键all_answer来修改请求的 List 并创建一个新的 List formatedRequest

结构体:-

     {
      "category": "History",
      "type": "multiple",
      "difficulty": "hard",
      "question": "With which Greek philosopher",
      "correct_answer": "Socrates",
      "incorrect_answers": [
        "Aristotle",
        "Plato",
        "Pythagoras"
      ]
    },
{},
{},
....,
....,
]```
                       need to convert it to
```List<Map<String, dynamic>> formatedRequest =[];```

STRUCTURE:-

```[
     {
      "category": "History",
      "type": "multiple",
      "difficulty": "hard",
      "question": "With which Greek philosopher",
      "correct_answer": "Socrates",
      "incorrect_answers": [
        "Aristotle",
        "Plato",
        "Pythagoras"
      ],
      "all_answers":[
        "Aristotle",
        "Plato",
        "Pythagoras",
        "Socrates"

       ]
    },
{},
{},
....,
....,
]```

标签: androidjsondartflutter

解决方案


推荐阅读