here the ex
Newtonsoft.Json.JsonSerializationException
Message=Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[CCSN.Models.Patient]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path '0', line 1, position 5.
in this line to get patient
return JsonConvert.DeserializeObject<TEntity>(json);
public static async Task<TEntity> Get<TEntity>(string url)
{
HttpClientHandler clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
HttpClient client = new HttpClient(clientHandler);
var response = await client.GetAsync(url);
var json = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<TEntity>(json);
}
is the error from not converting?
and how can i convert to object or json
this is the service to get Patient
public static async Task<IEnumerable<Patient>> GetUserPatients()
{
var url = await firebaseClient
.Child($"Specalists/406707265/Patients").BuildUrlAsync();
var result = await Helper.Get<List<Patient>>(url);
return result ;
}
Changed the Get type, to try to match the json
public static async Task<IEnumerable<Patient>> GetUserPatients()
{
var url = await firebaseClient
.Child($"Specalists/406707265/Patients").BuildUrlAsync();
var patientsDict = await Helper.Get<Dictionary<string, Patient>>(url);
var result = patientsDict.Values.ToList();
return result ;
}