Reputation: 3681
I have a response like below:
{
"status": false,
"errorDetails": [
"An Error Occured During Registration"
],
"userId": 0,
"schoolId": 0,
"planAmount": 0,
"discountId": 0,
"userProfileId": 0
}
I need to show the errorDetails content to UI if the status value is false. errorDetails is an array, so what was the type that I can use in the front end and how I can parse that value?
I tried like below:
public class SignUpResponse
{
public bool status { get; set; }
public string userProfileId { get; set; }
public List<string> errorDetails { get; set; }
}
string error = "";
if (signUpdetails.errorDetails.Count > 0)
{
error = signUpdetails.errorDetails[0];
}
if (!status)
{
await DisplayAlert("Alert", error.ToString(), "OK");
}
But this is not working, nothing is showing in the alert?
Upvotes: 0
Views: 77
Reputation: 785
Looks like a JSON response, is it being read into the object correctly? IE: there are errorDetails present in the object when you test?
Please confirm that both the overall object and the errorDetails are populated and not empty or null.
Upvotes: 1