I'm trying to deserialize an Object Array from an API service.
The data from the API has the following form:
{
"id": "9286",
"nome": "Bairro Novo",
"num_lotes": "312",
"num_quadras": "9",
"plots_id": "159351",
"geo_data": [
{
"loteamentos_id": "9286",
"G": "-7.27087569384820000000",
"K": "-34.90980863571200000000",
"index": "0",
"code": "V"
},
{
"loteamentos_id": "9286",
"G": "-7.27234968660550000000",
"K": "-34.90971207618700000000",
"index": "1",
"code": "V"
},
{
"loteamentos_id": "9286",
"G": "-7.27317448188540000000",
"K": "-34.90458905696900000000",
"index": "2",
"code": "V"
},
{
"loteamentos_id": "9286",
"G": "-7.27176434710060000000",
"K": "-34.90472316741900000000",
"index": "3",
"code": "V"
},
{
"loteamentos_id": "9286",
"G": "-7.27202508786680000000",
"K": "-34.90719884634000000000",
"index": "15",
"code": "C"
}
]
},
The class Loteamento:
public class Loteamento {
[JsonProperty("id")]
public string id { get; set; }
[JsonProperty("nome")]
public string nome { get; set; }
[JsonProperty("num_lotes")]
public string num_lotes { get; set; }
[JsonProperty("num_quadras")]
public string num_quadras { get; set; }
[JsonProperty("plots_id")]
public string plots_id { get; set; }
[JsonProperty("geo_data")]
public List<GeoData> geo_data { get; set; }
}
And the class GeoData:
public class GeoData {
[JsonProperty("loteamentos_id")]
public string loteamentos_id { get; set; }
[JsonProperty("G")]
public string G { get; set; }
[JsonProperty("K")]
public string K { get; set; }
[JsonProperty("index")]
public string index { get; set; }
[JsonProperty("code")]
public string code { get; set; }
}
The question is that I get an error and do not know how to get an Array.
In my code I have:
List<Loteamento>[] loteamentos = null;
loteamentos = JsonConvert.DeserializeObject<List<Loteamento>>(dataObj.Result);
What's wrong?