I get an exception when I try to deserialize to an object from a JSON string.
Newtonsoft.Json.JsonReaderException
Input string '106.890907 is not a valid integer. Path 'data[0].loc.coordinates[0]', line 1, position 9413.
This is how I deserialize the object:
var propertiesObj =
JsonConvert.DeserializeObject<Location>(
jsonObject);
And, this is how my json looks
{
"coordinates":
[
106.890907,
-6.149393
],
"type": "Point"
}
Finally, this is how I declare my model class:
Location.cs
public class Location
{
public List<double> coordinates { get; set; }
public string type { get; set; }
}
I have refer to this question on StackOverFlow but it did not solve my problem, link .
Please help. I have been unable to find any solution for this. Thanks.
Try this, update JSON:
From
"loc": {
"coordinates": [
106.890907,
-6.149393
],
"type": "Point"
}
To
{
"coordinates": [
106.890907,
-6.149393
],
"type": "Point"
}
ie Remove "loc" from Json
重新安装Windows 10之后,该错误神秘地消失了。
It's localization problem. You can set your CultureInfo for JsonConvert. I think your system accepts double with coma ( , ) not with dot ( . )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.