Here is my object
class CustomerDomain {
String customerID;
String citizenID;
String status;
String title;
String name;
String email;
String phoneNumber;
Map<String, ServiceDetail> serviceDetails;
int remainingMinute;
Map<String, ReferenceChannel> referenceChannels;
String omiseCustomerID;
CustomerDomain({
this.customerID,
this.citizenID,
this.status,
this.title,
this.name,
this.email,
this.phoneNumber,
this.serviceDetails,
this.remainingMinute,
this.referenceChannels,
this.omiseCustomerID,
});
factory CustomerDomain.fromJson(Map<String, dynamic> parsedJson) {
return CustomerDomain(
customerID: parsedJson['customerID'],
citizenID: parsedJson['citizenID'],
status: parsedJson['status'],
title: parsedJson['title'],
name: parsedJson['name'],
email: parsedJson['email'],
phoneNumber: parsedJson['phoneNumber'],
serviceDetails: parsedJson['serviceDetailsails'],
remainingMinute: parsedJson['remainingMinute'],
referenceChannels: parsedJson['referenceChannels'],
omiseCustomerID: parsedJson['omiseCustomerID'],
);
}
}
After calling a service, I return my response like this
if (response.statusCode == 200) {
print('entranceService3');
return CustomerDomain.fromJson(json.decode(response.body));
}
I printing the value like customerID and it works. But I cannot use print the value in the ReferenceChannel from referenceChannels. When I convert referenceChannels into list and then string, and print it. I got something like this
[{channel:channel1,code:code1,secondCode:code2}]
So, I think that I didn't map the json correctly because the value that has type Map<String, Object> didn't work properly when I try to the value of the object.