Last active
July 24, 2018 06:46
-
-
Save glyphx/985436e0aebd953633f50d3889d3fdff 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: | |
// | |
// using QuickType; | |
// | |
// var root = Root.FromJson(jsonString); | |
namespace QuickType | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Converters; | |
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