0

I am currently developing a twitch bot that monitors the users in the chat.

This site link will give you every user in the twitch stream / irc chat: http://tmi.twitch.tv/group/user/lirik/chatters.

For example I have given you lirik's chat. I need to get the folowing from the site:

"_links": {},
  "chatter_count": 0,
  "chatters": {
    "moderators": [],
    "staff": [],
    "admins": [],
    "global_mods": [],
    "viewers": []

Here is the code I have written so far to connect to the site and read the text:

WebClient web = new WebClient();
System.IO.Stream stream = web.OpenRead("http://tmi.twitch.tv/group/user/lirik/chatters");
using (System.IO.StreamReader reader = new System.IO.StreamReader(stream))
{
    String text = reader.ReadToEnd();
}

How can I turn the text from the site into multiple arrays?

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Cooper Scott
  • 651
  • 8
  • 18
  • when actually you would like to stop it and create a new array? – Slashy Aug 15 '15 at 18:34
  • @Slashy I would like to retrieve the array, or turn it into an array in my program. I need hold of the text in an array. – Cooper Scott Aug 15 '15 at 18:36
  • i understand but you're getting the content as string. So we would have to sort the string a split every time some content to array. that's why im asking when would you like to stop? each `,`? – Slashy Aug 15 '15 at 18:37
  • Yes @Slashy Sorry, didn't understand what you where asking. – Cooper Scott Aug 15 '15 at 18:38

1 Answers1

1

You are actually looking for Desiarializing Json into C# class.

So you should create class that describes your json structure ant then just use this kind of code:

YourClass jsonDeserializeObject = JsonConvert.DeserializeObject(text); //it's your text here

For more information of how you should write your class you can read msdn.

teo van kot
  • 12,350
  • 10
  • 38
  • 70