A game framework written with osu! in mind.
1// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2// See the LICENCE file in the repository root for full licence text.
3
4using Newtonsoft.Json;
5
6namespace osu.Framework.IO.Network
7{
8 /// <summary>
9 /// A web request with a specific JSON response format.
10 /// </summary>
11 /// <typeparam name="T">the response format.</typeparam>
12 public class JsonWebRequest<T> : WebRequest
13 {
14 protected override string Accept => "application/json";
15
16 public JsonWebRequest(string url = null, params object[] args)
17 : base(url, args)
18 {
19 }
20
21 protected override void ProcessResponse()
22 {
23 if (ResponseStream != null)
24 ResponseObject = JsonConvert.DeserializeObject<T>(GetResponseString());
25 }
26
27 public T ResponseObject { get; private set; }
28 }
29}