Возникла ошибка с json searilize
Код ошибки:
Newtonsoft.Json.JsonSerializationException: "Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Nullable`1[System.Int64]' because the type requires a JSON primitive value (e.g. string, number, boolean, null) to deserialize correctly.
To fix this error either change the JSON to a JSON primitive value (e.g. string, number, boolean, null) 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<T>) 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 'country.id', line 1, position 288."
Мой код:
Country countryjs = JsonConvert.DeserializeObject<Country>(abc);
Console.WriteLine(countryjs.Name.ToString());
Класс:
public partial class Country
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("urlName")]
public string UrlName { get; set; }
[JsonProperty("region", NullValueHandling = NullValueHandling.Ignore)]
public long? Region { get; set; }
[JsonProperty("country", NullValueHandling = NullValueHandling.Ignore)]
public long? CountryCountry { get; set; }
}
country:
