I am currently receiving something like this as json
[
{
"employee": {
"user": {
"first_name": "...",
"last_name": "Mob",
},
"employee_zip": 12345,
},
}
]
Notice the above is an array and not an object. This is what my dart file looks like
@JsonSerializable()
class myList extends Object with _$myListSerializerMixin {
@JsonKey(name: "")
final List<myResponse> response;
myList(this.response);
factory myList.fromJson(Map<String, dynamic> json) =>
_$portfolioResponseListFromJson(json);
}
Now when I try to do the following
myList foo = myList.fromJson(json.decode(response));
I get the exception:
[VERBOSE-2:dart_error.cc(16)] Unhandled exception:
type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>' where
List is from dart:core
Map is from dart:core
String is from dart:core
Any suggestions on how I can fix this ?