Распарсить JSON после GET запроса - C#

Узнай цену своей работы

Формулировка задачи:

Всем привет! Я делаю get запрос на сервер
static void Main()
        {
            WebRequest reqGET = WebRequest.Create(@"https://api.dubtrack.fm/room/nightblue3");
            WebResponse resp = reqGET.GetResponse();
            Stream stream = resp.GetResponseStream();
            StreamReader sr = new StreamReader(stream);
            string s = sr.ReadToEnd();
            Console.WriteLine(s);
            Console.ReadLine();
        }
И от туда получаю JSON файл
{"code":200,"message":"OK","data":{"_id":"56008abc239f1303009c92ec","__v":0,"_user":{"_id":"56008cfa239f1303009c93d0","username":"nb3","status":1,"roleid":1,"dubs":0,"created":1442876665823,"profileImage":{"version":1442876665,"width":48,"height":48,"format":"png","resource_type":"image","tags":[],"bytes":5303,"type":"upload","etag":"9d2198e1b7d40f3a1f5e122f7868e840","url":"http://res.cloudinary.com/hhberclba/image/upload/v1442876665/y4b7km2xtoqobdqzq543.png","secure_url":"https://res.cloudinary.com/hhberclba/image/upload/v1442876665/y4b7km2xtoqobdqzq543.png"},"__v":0},"activeUsers":142,"allowedDjs":0,"background":{"public_id":"qnkctyqwyereyo8j4uwc","version":1459164327,"width":1920,"height":1080,"format":"jpg","resource_type":"image","tags":[],"bytes":976228,"type":"upload","etag":"f763428f77662da80f2ce3d4627378ad","url":"http://res.cloudinary.com/hhberclba/image/upload/v1459164327/qnkctyqwyereyo8j4uwc.jpg","secure_url":"https://res.cloudinary.com/hhberclba/image/upload/v1459164327/qnkctyqwyereyo8j4uwc.jpg"},"created":1442876091570,"currentSong":{"songid":"57035ce87d1c444b00eebe51","type":"youtube","fkid":"N7jRV_rgagM","name":"AREA21 - Spaceships"},"description":"Stream: [url]https://www.twitch.tv/nightblue3\nBlackList:[/url] [url]http://git.io/vWJc7\nRules:[/url] http://git.io/vWJnY\n\n\n@dubx=https://rawgit.com/nightbloo/nightbloo.github.io/master/dubtrack/dubtrack.css","displayQueue":false,"isPublic":false,"lang":null,"maxLengthSong":7,"musicType":null,"name":"в™Є CHILL | TRAP | D&B в™Є","otSession":"1_MX40NDcxODM5Mn5-MTQ0Mjg3NjA5MTgyNH5BM2ZhUkJwRS9QeFFNQSs4bHA2YnZwSnB-UH4","password":null,"realTimeChannel":"dubtrackfm-nightblue3","roomEmbed":"","roomType":"room","roomUrl":"nightblue3","status":1,"updated":1442876091570,"userid":"56008cfa239f1303009c93d0","lockQueue":false,"welcomeMessage":"Welcome {username} to {roomname} ! Hope you enjoy the great music <3 Please read the rules if you are new: http://git.io/vWJnY","displayInLobby":true,"displayInSearch":true,"limitQueueLength":false,"timeSongQueueRepeat":240,"recycleDJ":true,"maxSongQueueLength":100,"roomDisplay":"public","metaDescription":"","displayDJinQueue":true,"displayUserJoin":false,"displayUserLeave":false,"displayUserGrab":false}}
Как распарсить Json строку name? ("name":"Bloodhound Gang - The Bad Touch (Gigi Barocco Bootleg)"})

Решение задачи: «Распарсить JSON после GET запроса»

textual
Листинг программы
            WebRequest reqGET = WebRequest.Create(@"https://api.dubtrack.fm/room/melharucos");
            WebResponse resp = reqGET.GetResponse();
            Stream stream = resp.GetResponseStream();
            StreamReader sr = new StreamReader(stream);
            string s = sr.ReadToEnd();
            JObject parsed = JObject.Parse(s);

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

7   голосов , оценка 4.143 из 5