I'm using this library (FireSharp) to access Firebase. I've retrieved a json as the body of a FirebaseResponse (status and body basically), which works good and looks like this (all test data):
"{\"Cobros\":{\"1001\":{\"Estado\":\"Cobrado\",\"Repartidor\":124},\"1112\":{\"Estado\":\"Pendiente\",\"Repartidor\":124}},\"Pedidos\":{\"1111\":{\"Estado\":\"Entregado\",\"Repartidor\":123}},\"Repartidores\":{\"123\":{\"ID Android\":\"asdadada\",\"Terminal\":123},\"124\":{\"ID Android\":\"dggrefawe\",\"Terminal\":124}}}"
The Firebase struct looks like this, leafs with some params behind that. I need to deserialize the Json to embed it into a Object with several List params, one for each node behind 18500. I've checked this question and this is my code so far:
public class cargaFirebase
{
[JsonProperty("Cobros")]
public List<documentoFirebase> carfb_cobros { get; set; }
[JsonProperty("Pedidos")]
public List<documentoFirebase> carfb_pedidos { get; set; }
[JsonProperty("Repartidores")]
public List<repartidorFirebase> carfb_repartidores { get; set; }
}
And the deserialization try...
FirebaseResponse resp = fbClient.Get(request);
cargaFirebase carga_res = JsonConvert.DeserializeObject<cargaFirebase>(resp.Body);
This gives me a deesrialization error I can't understand, not really into jsons sorry, and thx in advanced!
{Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[Reparto_Android.Code.Helpers.FirebaseHelper+documentoFirebase]' 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) 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