从JSON中提取字符串数组

时间:2016-06-24 15:01:34

标签: c# json twitch

如何从以下JSON中提取viewersstring[] people这样的数组?

{
  "_links": {},
  "chatter_count": 7,
  "chatters": {
    "moderators": [
      "moobot"
    ],
    "staff": [],
    "admins": [],
    "global_mods": [],
    "viewers": [
      "dzoomal94",
      "holeder",
      "koza1258",
      "kuba45209",
      "ufolud321",
      "varuulia"
    ]
  }
}

JSON取自此处:https://tmi.twitch.tv/group/user/lempiank/chatters

1 个答案:

答案 0 :(得分:0)

使用Json.Net你可以这样做:

JObject jo = JObject.Parse(json);
string[] people = jo.SelectToken("chatters.viewers").ToObject<string[]>();

小提琴:https://dotnetfiddle.net/lSXrUR