1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| // <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using CodeBeautify;
//
// var welcome4 = Welcome4.FromJson(jsonString);
namespace CodeBeautify
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class Welcome4
{
[JsonProperty("authenticated")]
public bool Authenticated { get; set; }
[JsonProperty("serverinfo")]
public Serverinfo[] Serverinfo { get; set; }
}
public partial struct Serverinfo
{
public string String;
public string[][] StringArrayArray;
public static implicit operator Serverinfo(string String) => new Serverinfo { String = String };
public static implicit operator Serverinfo(string[][] StringArrayArray) => new Serverinfo { StringArrayArray = StringArrayArray };
}
public partial class Welcome4
{
public static Welcome4 FromJson(string json) => JsonConvert.DeserializeObject<Welcome4>(json, CodeBeautify.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this Welcome4 self) => JsonConvert.SerializeObject(self, CodeBeautify.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
ServerinfoConverter.Singleton,
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
internal class ServerinfoConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(Serverinfo) || t == typeof(Serverinfo?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
switch (reader.TokenType)
{
case JsonToken.String:
case JsonToken.Date:
var stringValue = serializer.Deserialize<string>(reader);
return new Serverinfo { String = stringValue };
case JsonToken.StartArray:
var arrayValue = serializer.Deserialize<string[][]>(reader);
return new Serverinfo { StringArrayArray = arrayValue };
}
throw new Exception("Cannot unmarshal type Serverinfo");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
var value = (Serverinfo)untypedValue;
if (value.String != null)
{
serializer.Serialize(writer, value.String);
return;
}
if (value.StringArrayArray != null)
{
serializer.Serialize(writer, value.StringArrayArray);
return;
}
throw new Exception("Cannot marshal type Serverinfo");
}
public static readonly ServerinfoConverter Singleton = new ServerinfoConverter();
}
} |
Partager