Answer the question
In order to leave comments, you need to log in
Check if element exists in json?
Good afternoon, how can I check the presence of " CurrentSeasonGamesNeededForRating " c Newtonsoft.Json in the received json?
json example
{
"QueueSkills": {
"competitive": {
"CurrentSeasonGamesNeededForRating": 1,
"SeasonalInfoBySeasonID": null
}
}
}
Answer the question
In order to leave comments, you need to log in
Make the property Nullable and if it is null, then the value did not come at all. I think this is the easiest option, if you are not happy with the default value of 0 for the int type, which will be so even if the value of that property does not even come.
public class Competitive
{
[JsonProperty("CurrentSeasonGamesNeededForRating")]
public int? CurrentSeasonGamesNeededForRating { get; set; }
[JsonProperty("SeasonalInfoBySeasonID")]
public object SeasonalInfoBySeasonID { get; set; }
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question