I'm facing an issue when trying to parse a json from an API and I'm hitting the error below.
Response response= await Dio().post(url ,data:{"login_credential":_tmp_email,'password' : _tmp_password});
if ( response.statusCode == 200 ){
var parsedJson = json.decode(response.data);
print(parsedJson["result"]);
print(response.data);
}
} catch (e) {
print(e);
}
The error:
type '_InternalLinkedHashMap' is not a subtype of type 'String'
After some google searches and numerous tries of debugging. I came to a conclusion whereby it seems that the structure of the json returned is quite complex that's why parsing it normally will have problems.
The structure of the json is as follows.
{
result: 1,
msg: Login Success,
data: {
access_token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvYXNpYS1hbGxuZXQuY29tXC9hcGlcL21vYmlsZS12MVwvYXV0aC5tYW51YWwubG9naW4iLCJpYXQiOjE1NTUxNjQ4OTIsImV4cCI6MTU1NTE2NTAxMiwibmJmIjoxNTU1MTY0ODkyLCJqdGkiOiJjRGtLTVNOMlBmUTdwYjgzIiwic3ViIjo2MTksInBydiI6Ijg2NjVhZTk3NzVjZjI2ZjZiOGU0OTZmODZmYTUzNmQ2OGRkNzE4MTgifQ.YlmzG5bMbXV2_pMa9v5oRItdVBpM878ocfiGD0YS6Zo,
token_type: bearer,
expires_in: 119,
member: {
name: john, email: [email protected], id: 619, avatar_url:
https://example.com/images/img_avatar.png
}
}
}