3
{ "accuracy": 0.17, "dogr": 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)

1 Answer 1

3

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; 
Sign up to request clarification or add additional context in comments.

1 Comment

Be sure to cast the array over to a (JOBject) to allow the item to contain the Key Value pairs.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.