-1

How can we parse such type of List data in Flutter? I tried different models but failed. Following is the data:

[
    {
        "course":"Computer Architecture Fall 2018 - KHI",
        "pending_assignment":[
            {
                "name":"OOAD Project Fall 2018 Section B & D",
                "dueDate":"Dec 14, 2018 10:00 pm"
            }
        ]
    },
    {
        "course":"Object Oriented Analysis and Design Fall 2018 - KHI",
        "pending_assignment":[
            {
                "name":"OOAD Project Fall 2018 Section B & D",
                "dueDate":"Dec 14, 2018 10:00 pm"
            }
        ]
    }
]
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
Hassan Afzal
  • 125
  • 2
  • 6
  • "I tried different models but failed" what have you tried? How did you fail? https://flutter.io/docs/development/data-and-backend/json – Günter Zöchbauer Jan 08 '19 at 16:37
  • I tried the method defined there, but my data is in the form of list if you check it properly, and there is no such definition for that – Hassan Afzal Jan 08 '19 at 16:57
  • You need to (de)serialize each entry `myList.map((item) => deserializeJson(item)).toList()` I made up `deserializeJson`. Replace it with the code that does the deserialization or parsing. – Günter Zöchbauer Jan 08 '19 at 16:58
  • This question may probably have been answered here: https://stackoverflow.com/questions/51053954/how-to-deserialize-a-list-of-objects-from-json-in-flutter – furins Jan 20 '20 at 09:39

1 Answers1

-2

As you can check with this website (https://jsonformatter.org/json-parser), that JSON is not valid and contains errors.

For how to parse JSON in general, you can use the json.decode(jsonString); function from the dart:convert package. For more information on that you can check out this site: https://flutter.io/docs/development/data-and-backend/json

cb369
  • 7
  • 2
leodriesch
  • 5,308
  • 5
  • 30
  • 52