Using json webservice on Windows Phone 7

I am making a Windows phone application that can use json from this link http://dir.yummly.com/4/public/8a753a70358c827b01358da787bd68f3 , however, when I try to load the data asynchronously, I cannot get e.result on readable language. here is my c # code -

Uri sub4 = new Uri("http://dir.yummly.com/4/public/8a753a70358c827b01358da787bd68f3"); string kit = sub4.ToString(); WebClient w = new WebClient(); w.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted); w.DownloadStringAsync(sub4); MessageBox.Show("done"); } void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { string fres = e.Result;// here e.result was   } 

And then I want to deserialize e.result. My code works correctly for any other json url. And since I am working on a Windows Phone application, so I cannot use other webcilent methods such as DownloadData and DownloadString. I also saw a lot of conversions between utf8 and unicode, but none of them worked. Can anyone help?

+4
source share
2 answers

The API you click on serves gzipped content, and this is what you see as garbage text. Before use, you must unzip the contents. You can say this from the header:

 Content-Encoding: gzip 

Unfortunately, the last time I checked, the answers on GZip'ed in Windows Phone did not have built-in support. It shouldn't be too hard to create a workaround. When googling, the results show that the lowest solution for the solution adds the SharpGIS.GZipWebClient library from NuGet and uses GZip support there.

+2
source

You just follow below, it gives you a full explanation of how to consume and analyze json data from the server How to use Json Service in a wp7 application

+1
source

Source: https://habr.com/ru/post/1434379/


All Articles