namespace Monitorizacao.UI.Pages
{
public class Post {
public int Id { get; set; }
public string Title { get; set; }
public string Body { get; set; }
}
public partial class TestAPIPage : ContentPage
{
private const string url = "https://jsonplaceholder.typicode.com/posts";
private HttpClient _client = new HttpClient();
private ObservableCollection<Post> _posts;
public TestAPIPage()
{
InitializeComponent();
}
protected override async void OnAppearing()
{
var content = await _client.GetStringAsync(url);
var posts = JsonConvert.DeserializeObject<List<Post>>(content);
_posts = new ObservableCollection<Post>(posts);
List.ItemsSource = _posts;
Console.Write(posts);
base.OnAppearing();
}
}
}
I have a JSON and when I try to show it in a listview
after deserializing, the data does not show what I want.
When I the app, all data is received.