0
How to correctly parse a JSON string using Newtonsoft.json to an object in C#?

Open 0 Answers 18 Views Web Development

I'm creating a little system to let me see who is in my chat on Twitch using their JSON API. However, while I successfully got the information, I can't figure out how to parse it correctly.

This is the string that is being produced:

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

This is the object I created to deserialize it to, but I have no idea for sure if it's exactly correct:

public class users
{
    public string[] links;
    public int chatter_count;
    public string[] moderators;
    public string[] staff;
    public string[] admins;
    public string[] global_mods;
    public string[] viewers;
}

I'm using Newtonsoft.JSON to parse it - which would be the correct way to push the string to the "users" object?

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...