Created
July 24, 2018 12:06
-
-
Save glyphx/fffdbed1a3a5f9cdbe8bd3dbcb877540 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do: | |
// | |
// | |
// var root = Root.FromJson(jsonString); | |
namespace QuickType | |
{ | |
using System.Net; | |
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Converters; | |
using System.Threading; | |
static class GetJSON | |
{ | |
public static void GetJSONStuff() | |
{ | |
var url = "https://aionmine.org:22200/api/pools/aion/miners/0xa01394cb07a68c0079c23708a7be1212b9b8b4c1e7cc5c3c67b2b76530a8a449"; | |
var syncClient = new WebClient(); | |
var jsonString = syncClient.DownloadString(url); | |
var root = Root.FromJson(jsonString); | |
Console.WriteLine(root.PendingBalance); | |
//Console.WriteLine(jsonString); | |
} | |
static void Main() | |
{ | |
GetJSONStuff(); | |
Thread.Sleep(20000); | |
} | |
} | |
public partial class Root | |
{ | |
[JsonProperty("pendingShares")] | |
public long PendingShares { get; set; } | |
[JsonProperty("pendingBalance")] | |
public double PendingBalance { get; set; } | |
[JsonProperty("totalPaid")] | |
public double TotalPaid { get; set; } | |
[JsonProperty("lastPayment")] | |
public DateTimeOffset LastPayment { get; set; } | |
[JsonProperty("performance")] | |
public Performance Performance { get; set; } | |
[JsonProperty("performanceSamples")] | |
public Performance[] PerformanceSamples { get; set; } | |
} | |
public partial class Performance | |
{ | |
[JsonProperty("created")] | |
public DateTimeOffset Created { get; set; } | |
[JsonProperty("workers")] | |
public Dictionary<string, Worker> Workers { get; set; } | |
} | |
public partial class Worker | |
{ | |
[JsonProperty("hashrate")] | |
public double Hashrate { get; set; } | |
[JsonProperty("sharesPerSecond")] | |
public double SharesPerSecond { get; set; } | |
} | |
public partial class Root | |
{ | |
public static Root FromJson(string json) => JsonConvert.DeserializeObject<Root>(json, QuickType.Converter.Settings); | |
} | |
public static class Serialize | |
{ | |
public static string ToJson(this Root self) => JsonConvert.SerializeObject(self, QuickType.Converter.Settings); | |
} | |
internal static class Converter | |
{ | |
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings | |
{ | |
MetadataPropertyHandling = MetadataPropertyHandling.Ignore, | |
DateParseHandling = DateParseHandling.None, | |
Converters = { | |
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal } | |
}, | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment