I've been trying to retrieve all the data from the Firebase Database using the FireSharp on Windows Forms App, I want to convert it into the custom List, but when I do, it gives me an exeption.
I tried almost everything possible, my goal is to get data like this:
Users: 12345: name: "George" surname: "Gigauri" 234213: name: "Nika" surname: "Gigauri"
as:
12345, 234213 so I would retrieve their objects (like name, surname) later. I'm using the code:
private async void checkUser()
{
FirebaseResponse response = await client.GetAsync("Users");
List<Data> list = JsonConvert.DeserializeObject<List<Data>>(response.ToJson());
}
And it gives me an exception:
Newtonsoft.Json.JsonSerializationException
HResult=0x80131500
Message=Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[ConnectServer.Data]' 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 'Body', line 1, position 8.
Source=Newtonsoft.Json
StackTrace:
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
at ConnectServer.Form1.<checkUser>d__10.MoveNext() in D:\Microsoft Visual Studio\Projects\ConnectServer\ConnectServer\Form1.cs:line 101