Created
October 9, 2019 19:02
-
-
Save elbruno/021b4753497d41d2c88a3b8f39735c8c to your computer and use it in GitHub Desktop.
CustomVisionEstimation.cs
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
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Converters; | |
// created with https://app.quicktype.io/#l=cs&r= | |
namespace DistractedDriverDetectionShared | |
{ | |
public partial class CustomVisionEstimation | |
{ | |
[JsonProperty("created")] | |
public DateTimeOffset Created { get; set; } | |
[JsonProperty("id")] | |
public string Id { get; set; } | |
[JsonProperty("iteration")] | |
public string Iteration { get; set; } | |
[JsonProperty("predictions")] | |
public Prediction[] Predictions { get; set; } | |
[JsonProperty("project")] | |
public string Project { get; set; } | |
} | |
public partial class Prediction | |
{ | |
[JsonProperty("boundingBox")] | |
public object BoundingBox { get; set; } | |
[JsonProperty("probability")] | |
public double Probability { get; set; } | |
[JsonProperty("tagId")] | |
public string TagId { get; set; } | |
[JsonProperty("tagName")] | |
public string TagName { get; set; } | |
} | |
public partial class CustomVisionEstimation | |
{ | |
public static CustomVisionEstimation FromJson(string json) => JsonConvert.DeserializeObject<CustomVisionEstimation>(json, Converter.Settings); | |
} | |
public static class Serialize | |
{ | |
public static string ToJson(this CustomVisionEstimation self) => JsonConvert.SerializeObject(self, 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