JSON Object Help
{
"accuracy": 0.17,
"dog开发者_如何学Gor": 108,
"dogt": 22,
"elo0": 602.29,
"elo1": 587.28,
"games": 305
}
I have those values above from JSON Object,
JObject general = (JObject)bfbc_array[0]["general"];
foreach (float generalsNumbers in general.PropertyValues())
{
listBox7.Items.Add(generalsNumbers);
}
That loop iterates through the object and I can retrieve the number of each one. Which is perfect, however I want to retrieve the text as well and I'm completely stumped. What do I need to use so that I can get the text as well? (I am using JSON.NET)
You should be able to loop over general
as follows:
JObject general = (JObject)bfbc_array[0]["general"];
foreach (var item in general)
{
Console.WriteLine("{0} : {1}", item.Key, item.Value);
}
If you need the numbers to be of type float
you can cast them:
float value = (float)item.Value;
精彩评论