Skip to content

Instantly share code, notes, and snippets.

@glyphx
Last active July 24, 2018 06:46
Show Gist options
  • Save glyphx/985436e0aebd953633f50d3889d3fdff to your computer and use it in GitHub Desktop.
Save glyphx/985436e0aebd953633f50d3889d3fdff to your computer and use it in GitHub Desktop.
// 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