I am beginner to C# Windows Phone programming. I am developing an app in which I am getting a JSON response from the site using web client but I don't know how to parse it.
Could you help me from this?
Code:
public partial class MainPage : PhoneApplicationPage
{
// Constructor
public MainPage()
{
InitializeComponent();
}
private void btnRefreshTweets_Click(object sender, RoutedEventArgs e)
{
string winPhoneGeekTweetsUrl = @"http://ffff.xxxx.nxt/wpjson.php";
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new Uri(winPhoneGeekTweetsUrl));
}
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
return;
}
MessageBox.Show(e.Result );//-->this is where JSON response is displayed
}
}
wpjson.php
<?php
mysql_connect("mysql2.000webhost.com","12345","12345");
mysql_select_db("a1111111_forms");
$sql=mysql_query("SELECT * FROM newstable");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
echo json_encode($output);
?>
I also wanted it to be displayed in list.