I am trying to get data from firebase but it shows an error "Could not cast or convert from System.String to System.Collections.Generic.Dictionary`2"
This is my code:
IFirebaseConfig config = new FirebaseConfig()
{
AuthSecret = "Auth",
BasePath = "Path"
};
IFirebaseClient client;
private void Form1_Load(object sender, EventArgs e)
{
try
{
client = new FirebaseClient(config);
if (client != null)
{
MessageBox.Show("OK");
}
}
catch
{
MessageBox.Show("No");
}
LiveCall();
}
async void LiveCall()
{
while (true)
{
await Task.Delay(1000);
FirebaseResponse res = await client.GetAsync(@"GPS/lat");
Dictionary<string, GPS> data = JsonConvert.DeserializeObject<Dictionary<string, GPS>>(res.Body.ToString());
UpdateRTB(data);
}
}
void UpdateRTB(Dictionary<string, GPS> record)
{
label1.Text += record.ElementAt(1).Key + record.ElementAt(1).Value;
}
Can Anybody help me to solve the problem? thanks!