OK - I'm throwing in the towel on this. I've spent half day trying to parse a simple JSON object and none of the (at least 4) methods I've tried have worked. What the heck am I missing? The value of the JSON string is:
{
"CurrentVersion": "1.1.11",
"ID": "1",
"InstallerVersion": "1.0.0",
"LastVersion": "1.1.10",
"Name": "kart"
}
and no matter what I use (JsonConvert.DeserializeObject
, JavaScriptSerializer.Deserialize
or JsonSerializer.Deserialize
) the result is the same. The first, third and fourth values are null. I've tried changing those values in the JSON to strings, e.g.:
{
"CurrentVersion": "one",
"ID": "1",
"InstallerVersion": "two",
"LastVersion": "three",
"Name": "kart"
}
I tried changing the object value to Version
(it's currently just string); nothing works. There's got to be something simple I'm missing, but what?
Here's a picture of what I've tried so far:
For simplicity here's the code I've tried:
CurrentVersion currentVersion = js.Deserialize<CurrentVersion>(jsonResult);
currentVersion = JsonConvert.DeserializeObject<CurrentVersion>(jsonResult);
var version = System.Web.Script.Serialization.JavaScriptSerializer.Deserialize<currentVersion>(jsonResult);
currentVersion = JsonSerializer.Deserialize<CurrentVersion>(jsonResult,);