I would like to display this API content e.g.
Console.WriteLine(data.Title)
which would display
"Lembethe leading by example"
Have a look at my code
using (var webClient = new System.Net.WebClient())
{
var json = webClient.DownloadString(@"url");
var data = JsonConvert.DeserializeObject<Result>(json);
Console.WriteLine(data.Title);
}
These are my Classes below 1
public partial class Result
{
[JsonProperty("tags")]
public List<Tag> Tags { get; set; }
[JsonProperty("custom_tags")]
public List<string> CustomTags { get; set; }
[JsonProperty("id")]
public Guid Id { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("blurb")]
public string Blurb { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("published_at")]
public DateTimeOffset PublishedAt { get; set; }
[JsonProperty("thumbnail")]
public Banner Thumbnail { get; set; }
[JsonProperty("banner")]
public Banner Banner { get; set; }
}
These are my Classes below 2
public partial class Banner
{
[JsonProperty("small")]
public string Small { get; set; }
[JsonProperty("medium")]
public string Medium { get; set; }
[JsonProperty("large")]
public string Large { get; set; }
[JsonProperty("original")]
public string Original { get; set; }
}
where did I go wrong it does't even give me an error or output?
Resultis under theresultproperty, so you are missing a root class:public class SomeName{ public Result Result { get; set; } }