Hello guys, once again i am here to give you clear about, how you can parse JSON into the visible material into your application in presentable form. So, parsing JSON been hectic, I know, but we are going to make it easy together. To go through parsing things please follow the following steps after opening simple blank windows phone app :
- First of all you need to get the JSON file of some website and get it validated from http://jsonlint.com/.
- After you successfully validated the JSON, Now, you need to get it in the form of clases in order to get it done. So, for classes things you can convert it manually or paste the link in following to get the C-sharp classes code. json2charp
- you can use the link below to make it checked for your application http://yts.re/api/list.json
- Add the class now in you project named it as RootObject and put all the copied code from json2csharp into it.
- Now, simply put the button into your application to make things work manually and add the following code in it
WebClient web = new WebClient();
web.DownloadStringCompleted += web_DownloadStringCompleted;
- Now, in Routed event of downloadStringCompleted add the following
Note: here RootObject is class name movieList is the list placed into RootObject which is a list of another class named as MovieList in RootObject.cs
change it according to your requirement
var rootObject = JsonConvert.DeserializeObject<RootObject>(e.Result);
foreach (MovieList abc in rootObject.movieList)
- Now that you will see you can view the title in every object on the messageBox alert, which means you succesfully parsed the string.
if you get any problem you can reach me through comments, thanks