Skip to content

Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'String' #35253

@vivekanandasuggu

Description

@vivekanandasuggu

My model class is like this

import 'dart:convert';

List serviceLogsModelFromJson(String str) => new List.from(json.decode(str).map((x) => ServiceLogsModel.fromJson(x)));

String serviceLogsModelToJson(List data) => json.encode(new List.from(data.map((x) => x.toJson())));

class ServiceLogsModel {
String vitCasenumber;
String title;
DateTime createdon;
DateTime modifiedon;
String statuscodeODataCommunityDisplayV1FormattedValue;
int statecode;
String incidentid;
bool vitIsfilemandatory;
String customeridContact;
String vitFilesuploadedtosharepoint;
String vitJsondata;
int vitTypeofform;
bool vitReadstatus;

ServiceLogsModel({
this.vitCasenumber,
this.title,
this.createdon,
this.modifiedon,
this.statuscodeODataCommunityDisplayV1FormattedValue,
this.statecode,
this.incidentid,
this.vitIsfilemandatory,
this.customeridContact,
this.vitFilesuploadedtosharepoint,
this.vitJsondata,
this.vitTypeofform,
this.vitReadstatus,
});

factory ServiceLogsModel.fromJson(Map<String, dynamic> json) => new ServiceLogsModel(
vitCasenumber: json["vit_casenumber"],
title: json["title"],
createdon: DateTime.parse(json["createdon"]),
modifiedon: DateTime.parse(json["modifiedon"]),
statuscodeODataCommunityDisplayV1FormattedValue: json["[email protected]"],
statecode: json["statecode"],
incidentid: json["incidentid"],
vitIsfilemandatory: json["vit_isfilemandatory"],
customeridContact: json["customerid_contact"],
vitFilesuploadedtosharepoint: json["vit_filesuploadedtosharepoint"],
vitJsondata: json["vit_jsondata"],
vitTypeofform: json["vit_typeofform"],
vitReadstatus: json["vit_readstatus"],
);

Map<String, dynamic> toJson() => {
"vit_casenumber": vitCasenumber,
"title": title,
"createdon": createdon.toIso8601String(),
"modifiedon": modifiedon.toIso8601String(),
"[email protected]": statuscodeODataCommunityDisplayV1FormattedValue,
"statecode": statecode,
"incidentid": incidentid,
"vit_isfilemandatory": vitIsfilemandatory,
"customerid_contact": customeridContact,
"vit_filesuploadedtosharepoint": vitFilesuploadedtosharepoint,
"vit_jsondata": vitJsondata,
"vit_typeofform": vitTypeofform,
"vit_readstatus": vitReadstatus,
};
}
`

### I am getting the response like this
[
{
"vit_casenumber": "CM1902849",
"title": "Request For Reference Letter",
"createdon": "2019-06-27T04:43:44Z",
"modifiedon": "2019-06-27T04:54:03Z",
"[email protected]": "New",
"statecode": 0,
"incidentid": "e7d38720-9698-e911-a855-000d3ae0a7f8",
"vit_isfilemandatory": false,
"customerid_contact": null,
"vit_filesuploadedtosharepoint": null,
"vit_jsondata": null,
"vit_typeofform": 2,
"vit_readstatus": true
},
{
"vit_casenumber": "CM1902848",
"title": "Request For Reference Letter",
"createdon": "2019-06-26T12:53:13Z",
"modifiedon": "2019-06-26T12:53:17Z",
"[email protected]": "New",
"statecode": 0,
"incidentid": "681bb658-1198-e911-a852-000d3ae0b82e",
"vit_isfilemandatory": false,
"customerid_contact": null,
"vit_filesuploadedtosharepoint": null,
"vit_jsondata": null,
"vit_typeofform": 2,
"vit_readstatus": false
}
]

when I am executing this line

json.decode(response.body);

Getting the above issue. Please help me

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions