Well you would surely ask me, "Why without JSON.NET? ". Answer is really simple, its bad to have dependency of a library and you must know the other way around. When beta version of Windows 10 for developers was launched, I tried adding JSON.NET's old version and as a result I was not able to use it as a support for UWP apps since at that time it wasn't available. I just imagined that time,
"What if they don't provide support for Windows 10? ", "What if they end their support?". That made me move to native support of JSON parsing in Windows with help of,
using Windows.Data.Json;
It's a bit hard to parse JSON but according to me a Windows Developer should know both the ways to parse JSON.
- Using JSON.NET (Newtonsoft) Nuget package.
- Using Windows.Data.Json (Native Way).
Why is NewtonSoft (JSON.NET) so common when Windows Provide Native support for JSON parsing?
Well it started with Windows Phone (Silverlight) that didn't had native support for parsing JSON. Newtonsoft (JSON.NET) was one of the most efficient way to parse JSON on Windows Phone. More Windows Developers adopted it and used same way to parse JSON on Windows Phone, Windows Store and Web as well. It's easier to play with JSON. Then Microsoft introduced native support for parsing JSON which was Windows.Data.Json.
So for the time being just imagine there is no nuget package to parse JSON and you have to do it in a native way.

Let's discover how we can parse JSON using Windows.Data,Json;
Whenever you are parsing JSON you need to request data using Client. Well it's same for parsing Json.net way or native way.
Code:
First you need initialize client to request JSON data,
- var client = new HttpClient();
Code
- HttpResponseMessage response = await client.GetAsync(new Uri("http://hello987.azurewebsites.net/androidJson.html"));
Code
- var jsonString = await response.Content.ReadAsStringAsync();
As my JSON is a simple array so I just need to cast that to JSONArray and get out objects from that. I have saved my JSON respective C# class as "RootObject"
Code
- JsonArray root = JsonValue.Parse(jsonString).GetArray();
- for (uint i = 0; i < root.Count; i++) {
- string name1 = root.GetObjectAt(i).GetNamedString("name");
- string description1 = root.GetObjectAt(i).GetNamedString("description");
- string link1 = root.GetObjectAt(i).GetNamedString("link");
- string cat1 = root.GetObjectAt(i).GetNamedString("cat");
- string image1 = root.GetObjectAt(i).GetNamedString("image");
- var chan = new RootObject {
- name = name1, cat = cat1, description = description1, image = image1, link = link1
- };
- obs_channels.Add(chan);
- });

This is a basic example of Parsing JSON in native way. Practice hard and it would make your parsing skills perfect.
Hope this post was helpful, see you next time with an amazing post.

Grace AvrilinaPosted Jul 27, 2017, 3:47 AM
Where did u get getArray(), getObject()? i can't get it.
Prince AfolabiPosted Apr 4, 2017, 6:27 AM
Where did you get obs_channels
Matt GrunigPosted Feb 26, 2017, 10:50 AM
An error message at obs_channels.Add(chan); "Cannot resolve symbol 'obs_channels'" I'm beginner in UWP and I use Windows 10 + Phone. I use currently VS 2017 RC.
Gowtham RajamanickamPosted Apr 20, 2016, 8:38 AM
good share
Imran Javed ZiaPosted Dec 5, 2015, 8:05 AM
Nice Work
Santhakumar MunuswamyPosted Oct 25, 2015, 11:50 AM
Good one
Sibeesh VenuPosted Oct 21, 2015, 1:11 AM
Nice Share
Mukesh KumarPosted Oct 21, 2015, 12:36 AM
Good Work, Great
Mohammed IbrahimPosted Oct 20, 2015, 11:03 PM
nice
Priyaranjan K SPosted Oct 20, 2015, 12:28 PM
Nice Share
Nilesh JadavPosted Oct 20, 2015, 11:30 AM
This is awesome Great !!
Harshad PansuriyaPosted Oct 20, 2015, 9:04 AM
Nice one