Created
May 25, 2014 09:00
-
-
Save Tapanila/8ec04a4bf1d41c052aea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Net.Http; | |
| using Newtonsoft.Json; | |
| using Windows.UI.Xaml; | |
| using Windows.UI.Xaml.Controls; | |
| namespace TapanilaBlogJSON | |
| { | |
| public sealed partial class MainPage : Page | |
| { | |
| public MainPage() | |
| { | |
| this.InitializeComponent(); | |
| this.Loaded += MainPage_Loaded; | |
| } | |
| void MainPage_Loaded(object sender, RoutedEventArgs e) | |
| { | |
| consumeJson(); | |
| } | |
| async void consumeJson() | |
| { | |
| var httpClient = new HttpClient(); | |
| var jsonSource = new Uri("http://tapanila.net/api/get_recent_posts/?dev=1"); | |
| var response = await httpClient.GetAsync(jsonSource); | |
| var json = await response.Content.ReadAsStringAsync(); | |
| RootObject jsonObject = JsonConvert.DeserializeObject<RootObject>(json); | |
| foreach (var post in jsonObject.posts) | |
| { | |
| var title = post.title; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment