I'm writing my first C# application for Windows 10 IoT. I've got everything working, my web requests, etc and I am able to retrieve my desired content to render to the user. But...it's in JSON and I can't seem it into a regular variable so that I can pick just one property.
JSON Result
{
"date":"2017-07-09",
"period":"year",
"views":970347,
"visitors":150013,
"likes":136,
"reblogs":13,
"comments":1099,
"followers":145
}
I tried to add the Nuget package for NewtonSoft JSON (JSON.NET) and that doesn't seem to work on the rPI's ARM CPU. So I started to use the Windows.Data.JSON.JsonObject class instead.
I parse the JSON response for my app using JSonObject.Parse() with this line, and then when I debug, I see the following.
JsonObject meme = JsonObject.Parse(ResponseContent);
I can see all of the values I want right there under meme. JSonObject offers GetNamedString() and GetNamedObject() methods but I get terminating errors for both with: {"A method was called at an unexpected time.\r\n\r\nThis is not a string value. Use ValueType property to get the type."}
I'm coming from PowerShell, where I would just dump the response in $response and pull out the key/value pair with $Response.Views but I've got no idea how this is supposed to work in c#. What I really don't get is why it seems to stay in JSON after parsing it.
My goal is to assign the Followers and Visitors results from JSON to a variable so I can reference them later on. The webrequest works...I just can't seem to get the JSON to Parse.
