I have the following string that I want to convert into object City
. This doesn't work but throws:
Could not resolve type: global::Newtonsoft.Json.JsonConvert.DeserializeObject
Jsonstring:
{"result":{"id_city":"XX","city_name":"XXXX","city_province":"BW","city_country":"DE","city_zipcode":null,"city_gps_lat":"XXXXXX","city_gps_lng":"XXXXXX","city_gps_geohash":"XXXXXX","city_image":"XXXXXX","distance":11111}}
City class:
public class City
{
[JsonProperty("id_city")]
public string id_city { get; set; }
[JsonProperty("city_name")]
public string city_name { get; set; }
[JsonProperty("city_province")]
public string city_province { get; set; }
[JsonProperty("city_country")]
public string city_country { get; set; }
[JsonProperty("city_zipcode")]
public string city_zipcode { get; set; }
[JsonProperty("city_gps_lat")]
public string city_gps_lat { get; set; }
[JsonProperty("city_gps_lng")]
public string city_gps_lng { get; set; }
[JsonProperty("city_gps_geohash")]
public string city_gps_geohash { get; set; }
[JsonProperty("city_image")]
public string city_image { get; set; }
[JsonProperty("distance")]
public string distance { get; set; }
}
Method call:
City stadt = JsonConvert.DeserializeObject<City>(Jsonstring);
installed Newtonsoft.Json 8.0.3 over NuGet