Can't Deserialize Json Array
I know this question has been asked many times. But i'm still a newbie and it seems like I can't deserialize the json array I got from a get request. This is my code: Activity.cs
Solution 1:
Try using the following class to serialize to instead.
publicclassCarchingPointClass
{
publicstring _id { get; set; }
publicdouble price { get; set; }
publicstring type { get; set; }
publicstring model { get; set; }
publicstring modelID { get; set; }
publicdouble lat { get; set; }
publicdouble @long { get; set; }
publicstring address { get; set; }
publicint __v { get; set; }
publicstring modified_at { get; set; }
publicstring created_at { get; set; }
}
Then serialize using the following line.
var result=JsonConvert.DeserializeObject<List<CarchingPointClass>>(inputString)
Solution 2:
You have to use the line for Deserializing.
var result=JsonConvert.DeserializeObject<List<CarchingPointClass>>(inputString)
Class will be
publicclassCarchingPointClass
{
publicstring _id { get; set; }
publicdouble price { get; set; }
publicstring type { get; set; }
publicstring model { get; set; }
publicstring modelID { get; set; }
publicdouble lat { get; set; }
[JsonProperty("long")]
publicdouble lng { get; set; }
publicstring address { get; set; }
publicint __v { get; set; }
publicstring modified_at { get; set; }
publicstring created_at { get; set; }
}
Post a Comment for "Can't Deserialize Json Array"