0
votes

I have a json response from the API like below

     [{name:name1,email:[email protected],description:sss}, 
       {name:name2,email:[email protected],description:ttt}]

I tried to parse it and display it in list view. But i am getting the error like the one below while map the data and the error is "_TypeError (type 'String' is not a subtype of type 'Map<dynamic, dynamic>')".

    Map mappedData = jsonDecode(response);
1

1 Answers

0
votes

first, you should build a POJO model from your JSON then you use from this code:

var data = jsonDecode(dataresponse);
var result = data[0] as List;
setState(() {
 List<datamodel> zonelist = result.map<datamodel>((json) => 
    datamodel.fromJson(json)).toList();
});