Skip to content

EVE SDE Schema

Documentation for third-party developers

factions.jsonl

Schema

  • _key (required): integer
    Range: 500001 .. 500029
  • corporationID: integer
    Range: 1000035 .. 1000441
  • description (required): object

    • de (required): string
    • en (required): string
    • es (required): string
    • fr (required): string
    • ja (required): string
    • ko (required): string
    • ru (required): string
    • zh (required): string
  • flatLogo: string

  • flatLogoWithName: string
  • iconID (required): integer
    Range: 0 .. 25666
  • memberRaces (required): array of integer
    Type: integer
    Range: 1 .. 135
  • militiaCorporationID: integer
    Range: 1000179 .. 1000437
  • name (required): object

    • de (required): string
    • en (required): string
    • es (required): string
    • fr (required): string
    • ja (required): string
    • ko (required): string
    • ru (required): string
    • zh (required): string
  • shortDescription: object

    • de (required): string
    • en (required): string
    • es (required): string
    • fr (required): string
    • ja (required): string
    • ko (required): string
    • ru (required): string
    • zh (required): string
  • sizeFactor (required): number
    Range: 0 .. 5

  • solarSystemID (required): integer
    Range: 30000001 .. 30100000
  • uniqueName (required): boolean

Code snippets

// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
//    using QuickType;
//
//    var faction = Faction.FromJson(jsonString);

namespace QuickType
{
    using System;
    using System.Collections.Generic;

    using System.Globalization;
    using Newtonsoft.Json;
    using Newtonsoft.Json.Converters;

    public partial class Faction
    {
        [JsonProperty("_key")]
        public long Key { get; set; }

        [JsonProperty("corporationID", NullValueHandling = NullValueHandling.Ignore)]
        public long? CorporationId { get; set; }

        [JsonProperty("description")]
        public Description Description { get; set; }

        [JsonProperty("flatLogo", NullValueHandling = NullValueHandling.Ignore)]
        [JsonConverter(typeof(CunningMinMaxLengthCheckConverter))]
        public string FlatLogo { get; set; }

        [JsonProperty("flatLogoWithName", NullValueHandling = NullValueHandling.Ignore)]
        [JsonConverter(typeof(MagentaMinMaxLengthCheckConverter))]
        public string FlatLogoWithName { get; set; }

        [JsonProperty("iconID")]
        public long IconId { get; set; }

        [JsonProperty("memberRaces")]
        public long[] MemberRaces { get; set; }

        [JsonProperty("militiaCorporationID", NullValueHandling = NullValueHandling.Ignore)]
        public long? MilitiaCorporationId { get; set; }

        [JsonProperty("name")]
        public Name Name { get; set; }

        [JsonProperty("shortDescription", NullValueHandling = NullValueHandling.Ignore)]
        public ShortDescription ShortDescription { get; set; }

        [JsonProperty("sizeFactor")]
        [JsonConverter(typeof(MinMaxValueCheckConverter))]
        public double SizeFactor { get; set; }

        [JsonProperty("solarSystemID")]
        public long SolarSystemId { get; set; }

        [JsonProperty("uniqueName")]
        public bool UniqueName { get; set; }
    }

    public partial class Description
    {
        [JsonProperty("de")]
        [JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
        public string De { get; set; }

        [JsonProperty("en")]
        [JsonConverter(typeof(FluffyMinMaxLengthCheckConverter))]
        public string En { get; set; }

        [JsonProperty("es")]
        [JsonConverter(typeof(TentacledMinMaxLengthCheckConverter))]
        public string Es { get; set; }

        [JsonProperty("fr")]
        [JsonConverter(typeof(StickyMinMaxLengthCheckConverter))]
        public string Fr { get; set; }

        [JsonProperty("ja")]
        [JsonConverter(typeof(IndigoMinMaxLengthCheckConverter))]
        public string Ja { get; set; }

        [JsonProperty("ko")]
        [JsonConverter(typeof(IndecentMinMaxLengthCheckConverter))]
        public string Ko { get; set; }

        [JsonProperty("ru")]
        [JsonConverter(typeof(HilariousMinMaxLengthCheckConverter))]
        public string Ru { get; set; }

        [JsonProperty("zh")]
        [JsonConverter(typeof(AmbitiousMinMaxLengthCheckConverter))]
        public string Zh { get; set; }
    }

    public partial class Name
    {
        [JsonProperty("de")]
        [JsonConverter(typeof(FriskyMinMaxLengthCheckConverter))]
        public string De { get; set; }

        [JsonProperty("en")]
        [JsonConverter(typeof(FriskyMinMaxLengthCheckConverter))]
        public string En { get; set; }

        [JsonProperty("es")]
        [JsonConverter(typeof(MischievousMinMaxLengthCheckConverter))]
        public string Es { get; set; }

        [JsonProperty("fr")]
        [JsonConverter(typeof(BraggadociousMinMaxLengthCheckConverter))]
        public string Fr { get; set; }

        [JsonProperty("ja")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter1))]
        public string Ja { get; set; }

        [JsonProperty("ko")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter2))]
        public string Ko { get; set; }

        [JsonProperty("ru")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter3))]
        public string Ru { get; set; }

        [JsonProperty("zh")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter4))]
        public string Zh { get; set; }
    }

    public partial class ShortDescription
    {
        [JsonProperty("de")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter5))]
        public string De { get; set; }

        [JsonProperty("en")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter6))]
        public string En { get; set; }

        [JsonProperty("es")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter7))]
        public string Es { get; set; }

        [JsonProperty("fr")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter8))]
        public string Fr { get; set; }

        [JsonProperty("ja")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter9))]
        public string Ja { get; set; }

        [JsonProperty("ko")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter10))]
        public string Ko { get; set; }

        [JsonProperty("ru")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter11))]
        public string Ru { get; set; }

        [JsonProperty("zh")]
        [JsonConverter(typeof(MinMaxLengthCheckConverter12))]
        public string Zh { get; set; }
    }

    public partial class Faction
    {
        public static Faction FromJson(string json) => JsonConvert.DeserializeObject<Faction>(json, QuickType.Converter.Settings);
    }

    public static class Serialize
    {
        public static string ToJson(this Faction 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 }
            },
        };
    }

    internal class PurpleMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 9 && value.Length <= 1603)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 9 && value.Length <= 1603)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly PurpleMinMaxLengthCheckConverter Singleton = new PurpleMinMaxLengthCheckConverter();
    }

    internal class FluffyMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 7 && value.Length <= 1399)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 7 && value.Length <= 1399)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly FluffyMinMaxLengthCheckConverter Singleton = new FluffyMinMaxLengthCheckConverter();
    }

    internal class TentacledMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 11 && value.Length <= 1458)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 11 && value.Length <= 1458)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly TentacledMinMaxLengthCheckConverter Singleton = new TentacledMinMaxLengthCheckConverter();
    }

    internal class StickyMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 7 && value.Length <= 1447)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 7 && value.Length <= 1447)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly StickyMinMaxLengthCheckConverter Singleton = new StickyMinMaxLengthCheckConverter();
    }

    internal class IndigoMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 2 && value.Length <= 623)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 2 && value.Length <= 623)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly IndigoMinMaxLengthCheckConverter Singleton = new IndigoMinMaxLengthCheckConverter();
    }

    internal class IndecentMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 6 && value.Length <= 732)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 6 && value.Length <= 732)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly IndecentMinMaxLengthCheckConverter Singleton = new IndecentMinMaxLengthCheckConverter();
    }

    internal class HilariousMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 10 && value.Length <= 1501)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 10 && value.Length <= 1501)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly HilariousMinMaxLengthCheckConverter Singleton = new HilariousMinMaxLengthCheckConverter();
    }

    internal class AmbitiousMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 2 && value.Length <= 390)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 2 && value.Length <= 390)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly AmbitiousMinMaxLengthCheckConverter Singleton = new AmbitiousMinMaxLengthCheckConverter();
    }

    internal class CunningMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 8 && value.Length <= 18)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 8 && value.Length <= 18)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly CunningMinMaxLengthCheckConverter Singleton = new CunningMinMaxLengthCheckConverter();
    }

    internal class MagentaMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 20 && value.Length <= 27)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 20 && value.Length <= 27)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MagentaMinMaxLengthCheckConverter Singleton = new MagentaMinMaxLengthCheckConverter();
    }

    internal class FriskyMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 3 && value.Length <= 42)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 3 && value.Length <= 42)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly FriskyMinMaxLengthCheckConverter Singleton = new FriskyMinMaxLengthCheckConverter();
    }

    internal class MischievousMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 3 && value.Length <= 51)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 3 && value.Length <= 51)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MischievousMinMaxLengthCheckConverter Singleton = new MischievousMinMaxLengthCheckConverter();
    }

    internal class BraggadociousMinMaxLengthCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 3 && value.Length <= 43)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 3 && value.Length <= 43)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly BraggadociousMinMaxLengthCheckConverter Singleton = new BraggadociousMinMaxLengthCheckConverter();
    }

    internal class MinMaxLengthCheckConverter1 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 2 && value.Length <= 14)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 2 && value.Length <= 14)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter1 Singleton = new MinMaxLengthCheckConverter1();
    }

    internal class MinMaxLengthCheckConverter2 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 3 && value.Length <= 13)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 3 && value.Length <= 13)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter2 Singleton = new MinMaxLengthCheckConverter2();
    }

    internal class MinMaxLengthCheckConverter3 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 7 && value.Length <= 41)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 7 && value.Length <= 41)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter3 Singleton = new MinMaxLengthCheckConverter3();
    }

    internal class MinMaxLengthCheckConverter4 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 2 && value.Length <= 13)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 2 && value.Length <= 13)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter4 Singleton = new MinMaxLengthCheckConverter4();
    }

    internal class MinMaxLengthCheckConverter5 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 87 && value.Length <= 106)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 87 && value.Length <= 106)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter5 Singleton = new MinMaxLengthCheckConverter5();
    }

    internal class MinMaxLengthCheckConverter6 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 77 && value.Length <= 88)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 77 && value.Length <= 88)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter6 Singleton = new MinMaxLengthCheckConverter6();
    }

    internal class MinMaxLengthCheckConverter7 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 72 && value.Length <= 93)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 72 && value.Length <= 93)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter7 Singleton = new MinMaxLengthCheckConverter7();
    }

    internal class MinMaxLengthCheckConverter8 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 70 && value.Length <= 100)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 70 && value.Length <= 100)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter8 Singleton = new MinMaxLengthCheckConverter8();
    }

    internal class MinMaxLengthCheckConverter9 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 26 && value.Length <= 37)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 26 && value.Length <= 37)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter9 Singleton = new MinMaxLengthCheckConverter9();
    }

    internal class MinMaxLengthCheckConverter10 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 31 && value.Length <= 46)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 31 && value.Length <= 46)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter10 Singleton = new MinMaxLengthCheckConverter10();
    }

    internal class MinMaxLengthCheckConverter11 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 59 && value.Length <= 90)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 59 && value.Length <= 90)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter11 Singleton = new MinMaxLengthCheckConverter11();
    }

    internal class MinMaxLengthCheckConverter12 : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(string);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            var value = serializer.Deserialize<string>(reader);
            if (value.Length >= 18 && value.Length <= 22)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type string");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            var value = (string)untypedValue;
            if (value.Length >= 18 && value.Length <= 22)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type string");
        }

        public static readonly MinMaxLengthCheckConverter12 Singleton = new MinMaxLengthCheckConverter12();
    }

    internal class MinMaxValueCheckConverter : JsonConverter
    {
        public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);

        public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
        {
            if (reader.TokenType == JsonToken.Null) return null;
            var value = serializer.Deserialize<double>(reader);
            if (value >= 0 && value <= 5)
            {
                return value;
            }
            throw new Exception("Cannot unmarshal type double");
        }

        public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
        {
            if (untypedValue == null)
            {
                serializer.Serialize(writer, null);
                return;
            }
            var value = (double)untypedValue;
            if (value >= 0 && value <= 5)
            {
                serializer.Serialize(writer, value);
                return;
            }
            throw new Exception("Cannot marshal type double");
        }

        public static readonly MinMaxValueCheckConverter Singleton = new MinMaxValueCheckConverter();
    }
}
// Code generated from JSON Schema using quicktype. DO NOT EDIT.
// To parse and unparse this JSON data, add this code to your project and do:
//
//    faction, err := UnmarshalFaction(bytes)
//    bytes, err = faction.Marshal()

package model

import "encoding/json"

func UnmarshalFaction(data []byte) (Faction, error) {
    var r Faction
    err := json.Unmarshal(data, &r)
    return r, err
}

func (r *Faction) Marshal() ([]byte, error) {
    return json.Marshal(r)
}

type Faction struct {
    Key                  int64             `json:"_key"`
    CorporationID        *int64            `json:"corporationID,omitempty"`
    Description          Description       `json:"description"`
    FlatLogo             *string           `json:"flatLogo,omitempty"`
    FlatLogoWithName     *string           `json:"flatLogoWithName,omitempty"`
    IconID               int64             `json:"iconID"`
    MemberRaces          []int64           `json:"memberRaces"`
    MilitiaCorporationID *int64            `json:"militiaCorporationID,omitempty"`
    Name                 Name              `json:"name"`
    ShortDescription     *ShortDescription `json:"shortDescription,omitempty"`
    SizeFactor           float64           `json:"sizeFactor"`
    SolarSystemID        int64             `json:"solarSystemID"`
    UniqueName           bool              `json:"uniqueName"`
}

type Description struct {
    De string `json:"de"`
    En string `json:"en"`
    Es string `json:"es"`
    Fr string `json:"fr"`
    Ja string `json:"ja"`
    Ko string `json:"ko"`
    Ru string `json:"ru"`
    Zh string `json:"zh"`
}

type Name struct {
    De string `json:"de"`
    En string `json:"en"`
    Es string `json:"es"`
    Fr string `json:"fr"`
    Ja string `json:"ja"`
    Ko string `json:"ko"`
    Ru string `json:"ru"`
    Zh string `json:"zh"`
}

type ShortDescription struct {
    De string `json:"de"`
    En string `json:"en"`
    Es string `json:"es"`
    Fr string `json:"fr"`
    Ja string `json:"ja"`
    Ko string `json:"ko"`
    Ru string `json:"ru"`
    Zh string `json:"zh"`
}
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
        "_key": {
            "type": "integer",
            "minimum": 500001,
            "maximum": 500029
        },
        "corporationID": {
            "type": "integer",
            "minimum": 1000035,
            "maximum": 1000441
        },
        "description": {
            "type": "object",
            "properties": {
                "de": {
                    "type": "string",
                    "minLength": 9,
                    "maxLength": 1603
                },
                "en": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 1399
                },
                "es": {
                    "type": "string",
                    "minLength": 11,
                    "maxLength": 1458
                },
                "fr": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 1447
                },
                "ja": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 623
                },
                "ko": {
                    "type": "string",
                    "minLength": 6,
                    "maxLength": 732
                },
                "ru": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 1501
                },
                "zh": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 390
                }
            },
            "required": [
                "de",
                "en",
                "es",
                "fr",
                "ja",
                "ko",
                "ru",
                "zh"
            ]
        },
        "flatLogo": {
            "type": "string",
            "minLength": 8,
            "maxLength": 18
        },
        "flatLogoWithName": {
            "type": "string",
            "minLength": 20,
            "maxLength": 27
        },
        "iconID": {
            "type": "integer",
            "minimum": 0,
            "maximum": 25666
        },
        "memberRaces": {
            "type": "array",
            "items": {
                "type": "integer",
                "minimum": 1,
                "maximum": 135
            },
            "minItems": 1,
            "maxItems": 5
        },
        "militiaCorporationID": {
            "type": "integer",
            "minimum": 1000179,
            "maximum": 1000437
        },
        "name": {
            "type": "object",
            "properties": {
                "de": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 42
                },
                "en": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 42
                },
                "es": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 51
                },
                "fr": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 43
                },
                "ja": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 14
                },
                "ko": {
                    "type": "string",
                    "minLength": 3,
                    "maxLength": 13
                },
                "ru": {
                    "type": "string",
                    "minLength": 7,
                    "maxLength": 41
                },
                "zh": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 13
                }
            },
            "required": [
                "de",
                "en",
                "es",
                "fr",
                "ja",
                "ko",
                "ru",
                "zh"
            ]
        },
        "shortDescription": {
            "type": "object",
            "properties": {
                "de": {
                    "type": "string",
                    "minLength": 87,
                    "maxLength": 106
                },
                "en": {
                    "type": "string",
                    "minLength": 77,
                    "maxLength": 88
                },
                "es": {
                    "type": "string",
                    "minLength": 72,
                    "maxLength": 93
                },
                "fr": {
                    "type": "string",
                    "minLength": 70,
                    "maxLength": 100
                },
                "ja": {
                    "type": "string",
                    "minLength": 26,
                    "maxLength": 37
                },
                "ko": {
                    "type": "string",
                    "minLength": 31,
                    "maxLength": 46
                },
                "ru": {
                    "type": "string",
                    "minLength": 59,
                    "maxLength": 90
                },
                "zh": {
                    "type": "string",
                    "minLength": 18,
                    "maxLength": 22
                }
            },
            "required": [
                "de",
                "en",
                "es",
                "fr",
                "ja",
                "ko",
                "ru",
                "zh"
            ]
        },
        "sizeFactor": {
            "type": "number",
            "minimum": 0.0,
            "maximum": 5.0
        },
        "solarSystemID": {
            "type": "integer",
            "minimum": 30000001,
            "maximum": 30100000
        },
        "uniqueName": {
            "type": "boolean"
        }
    },
    "required": [
        "_key",
        "description",
        "iconID",
        "memberRaces",
        "name",
        "sizeFactor",
        "solarSystemID",
        "uniqueName"
    ]
}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json    = Json { allowStructuredMapKeys = true }
// val faction = json.parse(Faction.serializer(), jsonString)

package model

import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*

@Serializable
data class Faction (
    @SerialName("_key")
    val key: Long,

    @SerialName("corporationID")
    val corporationId: Long? = null,

    val description: Description,
    val flatLogo: String? = null,
    val flatLogoWithName: String? = null,

    @SerialName("iconID")
    val iconId: Long,

    val memberRaces: List<Long>,

    @SerialName("militiaCorporationID")
    val militiaCorporationId: Long? = null,

    val name: Name,
    val shortDescription: ShortDescription? = null,
    val sizeFactor: Double,

    @SerialName("solarSystemID")
    val solarSystemId: Long,

    val uniqueName: Boolean
)

@Serializable
data class Description (
    val de: String,
    val en: String,
    val es: String,
    val fr: String,
    val ja: String,
    val ko: String,
    val ru: String,
    val zh: String
)

@Serializable
data class Name (
    val de: String,
    val en: String,
    val es: String,
    val fr: String,
    val ja: String,
    val ko: String,
    val ru: String,
    val zh: String
)

@Serializable
data class ShortDescription (
    val de: String,
    val en: String,
    val es: String,
    val fr: String,
    val ja: String,
    val ko: String,
    val ru: String,
    val zh: String
)
<?php

// This is a autogenerated file:Faction

class Faction {
    private int $key; // json:_key Required
    private ?int $corporationId; // json:corporationID Optional
    private Description $description; // json:description Required
    private ?string $flatLogo; // json:flatLogo Optional
    private ?string $flatLogoWithName; // json:flatLogoWithName Optional
    private int $iconId; // json:iconID Required
    private array $memberRaces; // json:memberRaces Required
    private ?int $militiaCorporationId; // json:militiaCorporationID Optional
    private Name $name; // json:name Required
    private ?ShortDescription $shortDescription; // json:shortDescription Optional
    private float $sizeFactor; // json:sizeFactor Required
    private int $solarSystemId; // json:solarSystemID Required
    private bool $uniqueName; // json:uniqueName Required

    /**
     * @param int $key
     * @param int|null $corporationId
     * @param Description $description
     * @param string|null $flatLogo
     * @param string|null $flatLogoWithName
     * @param int $iconId
     * @param array $memberRaces
     * @param int|null $militiaCorporationId
     * @param Name $name
     * @param ShortDescription|null $shortDescription
     * @param float $sizeFactor
     * @param int $solarSystemId
     * @param bool $uniqueName
     */
    public function __construct(int $key, ?int $corporationId, Description $description, ?string $flatLogo, ?string $flatLogoWithName, int $iconId, array $memberRaces, ?int $militiaCorporationId, Name $name, ?ShortDescription $shortDescription, float $sizeFactor, int $solarSystemId, bool $uniqueName) {
        $this->key = $key;
        $this->corporationId = $corporationId;
        $this->description = $description;
        $this->flatLogo = $flatLogo;
        $this->flatLogoWithName = $flatLogoWithName;
        $this->iconId = $iconId;
        $this->memberRaces = $memberRaces;
        $this->militiaCorporationId = $militiaCorporationId;
        $this->name = $name;
        $this->shortDescription = $shortDescription;
        $this->sizeFactor = $sizeFactor;
        $this->solarSystemId = $solarSystemId;
        $this->uniqueName = $uniqueName;
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromKey(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toKey(): int {
        if (Faction::validateKey($this->key))  {
            return $this->key; /*int*/
        }
        throw new Exception('never get to this Faction::key');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateKey(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:Faction::key");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getKey(): int {
        if (Faction::validateKey($this->key))  {
            return $this->key;
        }
        throw new Exception('never get to getKey Faction::key');
    }

    /**
     * @return int
     */
    public static function sampleKey(): int {
        return 31; /*31:key*/
    }

    /**
     * @param ?int $value
     * @throws Exception
     * @return ?int
     */
    public static function fromCorporationId(?int $value): ?int {
        if (!is_null($value)) {
            return $value; /*int*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function toCorporationId(): ?int {
        if (Faction::validateCorporationId($this->corporationId))  {
            if (!is_null($this->corporationId)) {
                return $this->corporationId; /*int*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Faction::corporationId');
    }

    /**
     * @param int|null
     * @return bool
     * @throws Exception
     */
    public static function validateCorporationId(?int $value): bool {
        if (!is_null($value)) {
            if (!is_integer($value)) {
                throw new Exception("Attribute Error:Faction::corporationId");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function getCorporationId(): ?int {
        if (Faction::validateCorporationId($this->corporationId))  {
            return $this->corporationId;
        }
        throw new Exception('never get to getCorporationId Faction::corporationId');
    }

    /**
     * @return ?int
     */
    public static function sampleCorporationId(): ?int {
        return 32; /*32:corporationId*/
    }

    /**
     * @param stdClass $value
     * @throws Exception
     * @return Description
     */
    public static function fromDescription(stdClass $value): Description {
        return Description::from($value); /*class*/
    }

    /**
     * @throws Exception
     * @return stdClass
     */
    public function toDescription(): stdClass {
        if (Faction::validateDescription($this->description))  {
            return $this->description->to(); /*class*/
        }
        throw new Exception('never get to this Faction::description');
    }

    /**
     * @param Description
     * @return bool
     * @throws Exception
     */
    public static function validateDescription(Description $value): bool {
        $value->validate();
        return true;
    }

    /**
     * @throws Exception
     * @return Description
     */
    public function getDescription(): Description {
        if (Faction::validateDescription($this->description))  {
            return $this->description;
        }
        throw new Exception('never get to getDescription Faction::description');
    }

    /**
     * @return Description
     */
    public static function sampleDescription(): Description {
        return Description::sample(); /*33:description*/
    }

    /**
     * @param ?string $value
     * @throws Exception
     * @return ?string
     */
    public static function fromFlatLogo(?string $value): ?string {
        if (!is_null($value)) {
            return $value; /*string*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?string
     */
    public function toFlatLogo(): ?string {
        if (Faction::validateFlatLogo($this->flatLogo))  {
            if (!is_null($this->flatLogo)) {
                return $this->flatLogo; /*string*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Faction::flatLogo');
    }

    /**
     * @param string|null
     * @return bool
     * @throws Exception
     */
    public static function validateFlatLogo(?string $value): bool {
        if (!is_null($value)) {
            if (!is_string($value)) {
                throw new Exception("Attribute Error:Faction::flatLogo");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?string
     */
    public function getFlatLogo(): ?string {
        if (Faction::validateFlatLogo($this->flatLogo))  {
            return $this->flatLogo;
        }
        throw new Exception('never get to getFlatLogo Faction::flatLogo');
    }

    /**
     * @return ?string
     */
    public static function sampleFlatLogo(): ?string {
        return 'Faction::flatLogo::34'; /*34:flatLogo*/
    }

    /**
     * @param ?string $value
     * @throws Exception
     * @return ?string
     */
    public static function fromFlatLogoWithName(?string $value): ?string {
        if (!is_null($value)) {
            return $value; /*string*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?string
     */
    public function toFlatLogoWithName(): ?string {
        if (Faction::validateFlatLogoWithName($this->flatLogoWithName))  {
            if (!is_null($this->flatLogoWithName)) {
                return $this->flatLogoWithName; /*string*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Faction::flatLogoWithName');
    }

    /**
     * @param string|null
     * @return bool
     * @throws Exception
     */
    public static function validateFlatLogoWithName(?string $value): bool {
        if (!is_null($value)) {
            if (!is_string($value)) {
                throw new Exception("Attribute Error:Faction::flatLogoWithName");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?string
     */
    public function getFlatLogoWithName(): ?string {
        if (Faction::validateFlatLogoWithName($this->flatLogoWithName))  {
            return $this->flatLogoWithName;
        }
        throw new Exception('never get to getFlatLogoWithName Faction::flatLogoWithName');
    }

    /**
     * @return ?string
     */
    public static function sampleFlatLogoWithName(): ?string {
        return 'Faction::flatLogoWithName::35'; /*35:flatLogoWithName*/
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromIconId(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toIconId(): int {
        if (Faction::validateIconId($this->iconId))  {
            return $this->iconId; /*int*/
        }
        throw new Exception('never get to this Faction::iconId');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateIconId(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:Faction::iconId");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getIconId(): int {
        if (Faction::validateIconId($this->iconId))  {
            return $this->iconId;
        }
        throw new Exception('never get to getIconId Faction::iconId');
    }

    /**
     * @return int
     */
    public static function sampleIconId(): int {
        return 36; /*36:iconId*/
    }

    /**
     * @param array $value
     * @throws Exception
     * @return array
     */
    public static function fromMemberRaces(array $value): array {
        return  array_map(function ($value) {
            return $value; /*int*/
        }, $value);
    }

    /**
     * @throws Exception
     * @return array
     */
    public function toMemberRaces(): array {
        if (Faction::validateMemberRaces($this->memberRaces))  {
            return array_map(function ($value) {
                return $value; /*int*/
            }, $this->memberRaces);
        }
        throw new Exception('never get to this Faction::memberRaces');
    }

    /**
     * @param array
     * @return bool
     * @throws Exception
     */
    public static function validateMemberRaces(array $value): bool {
        if (!is_array($value)) {
            throw new Exception("Attribute Error:Faction::memberRaces");
        }
        array_walk($value, function($value_v) {
            if (!is_integer($value_v)) {
                throw new Exception("Attribute Error:Faction::memberRaces");
            }
        });
        return true;
    }

    /**
     * @throws Exception
     * @return array
     */
    public function getMemberRaces(): array {
        if (Faction::validateMemberRaces($this->memberRaces))  {
            return $this->memberRaces;
        }
        throw new Exception('never get to getMemberRaces Faction::memberRaces');
    }

    /**
     * @return array
     */
    public static function sampleMemberRaces(): array {
        return  array(
            37 /*37:*/
        ); /* 37:memberRaces*/
    }

    /**
     * @param ?int $value
     * @throws Exception
     * @return ?int
     */
    public static function fromMilitiaCorporationId(?int $value): ?int {
        if (!is_null($value)) {
            return $value; /*int*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function toMilitiaCorporationId(): ?int {
        if (Faction::validateMilitiaCorporationId($this->militiaCorporationId))  {
            if (!is_null($this->militiaCorporationId)) {
                return $this->militiaCorporationId; /*int*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Faction::militiaCorporationId');
    }

    /**
     * @param int|null
     * @return bool
     * @throws Exception
     */
    public static function validateMilitiaCorporationId(?int $value): bool {
        if (!is_null($value)) {
            if (!is_integer($value)) {
                throw new Exception("Attribute Error:Faction::militiaCorporationId");
            }
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?int
     */
    public function getMilitiaCorporationId(): ?int {
        if (Faction::validateMilitiaCorporationId($this->militiaCorporationId))  {
            return $this->militiaCorporationId;
        }
        throw new Exception('never get to getMilitiaCorporationId Faction::militiaCorporationId');
    }

    /**
     * @return ?int
     */
    public static function sampleMilitiaCorporationId(): ?int {
        return 38; /*38:militiaCorporationId*/
    }

    /**
     * @param stdClass $value
     * @throws Exception
     * @return Name
     */
    public static function fromName(stdClass $value): Name {
        return Name::from($value); /*class*/
    }

    /**
     * @throws Exception
     * @return stdClass
     */
    public function toName(): stdClass {
        if (Faction::validateName($this->name))  {
            return $this->name->to(); /*class*/
        }
        throw new Exception('never get to this Faction::name');
    }

    /**
     * @param Name
     * @return bool
     * @throws Exception
     */
    public static function validateName(Name $value): bool {
        $value->validate();
        return true;
    }

    /**
     * @throws Exception
     * @return Name
     */
    public function getName(): Name {
        if (Faction::validateName($this->name))  {
            return $this->name;
        }
        throw new Exception('never get to getName Faction::name');
    }

    /**
     * @return Name
     */
    public static function sampleName(): Name {
        return Name::sample(); /*39:name*/
    }

    /**
     * @param ?stdClass $value
     * @throws Exception
     * @return ?ShortDescription
     */
    public static function fromShortDescription(?stdClass $value): ?ShortDescription {
        if (!is_null($value)) {
            return ShortDescription::from($value); /*class*/
        } else {
            return null;
        }
    }

    /**
     * @throws Exception
     * @return ?stdClass
     */
    public function toShortDescription(): ?stdClass {
        if (Faction::validateShortDescription($this->shortDescription))  {
            if (!is_null($this->shortDescription)) {
                return $this->shortDescription->to(); /*class*/
            } else {
                return  null;
            }
        }
        throw new Exception('never get to this Faction::shortDescription');
    }

    /**
     * @param ShortDescription|null
     * @return bool
     * @throws Exception
     */
    public static function validateShortDescription(?ShortDescription $value): bool {
        if (!is_null($value)) {
            $value->validate();
        }
        return true;
    }

    /**
     * @throws Exception
     * @return ?ShortDescription
     */
    public function getShortDescription(): ?ShortDescription {
        if (Faction::validateShortDescription($this->shortDescription))  {
            return $this->shortDescription;
        }
        throw new Exception('never get to getShortDescription Faction::shortDescription');
    }

    /**
     * @return ?ShortDescription
     */
    public static function sampleShortDescription(): ?ShortDescription {
        return ShortDescription::sample(); /*40:shortDescription*/
    }

    /**
     * @param float $value
     * @throws Exception
     * @return float
     */
    public static function fromSizeFactor(float $value): float {
        return $value; /*float*/
    }

    /**
     * @throws Exception
     * @return float
     */
    public function toSizeFactor(): float {
        if (Faction::validateSizeFactor($this->sizeFactor))  {
            return $this->sizeFactor; /*float*/
        }
        throw new Exception('never get to this Faction::sizeFactor');
    }

    /**
     * @param float
     * @return bool
     * @throws Exception
     */
    public static function validateSizeFactor(float $value): bool {
        if (!is_float($value)) {
            throw new Exception("Attribute Error:Faction::sizeFactor");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return float
     */
    public function getSizeFactor(): float {
        if (Faction::validateSizeFactor($this->sizeFactor))  {
            return $this->sizeFactor;
        }
        throw new Exception('never get to getSizeFactor Faction::sizeFactor');
    }

    /**
     * @return float
     */
    public static function sampleSizeFactor(): float {
        return 41.041; /*41:sizeFactor*/
    }

    /**
     * @param int $value
     * @throws Exception
     * @return int
     */
    public static function fromSolarSystemId(int $value): int {
        return $value; /*int*/
    }

    /**
     * @throws Exception
     * @return int
     */
    public function toSolarSystemId(): int {
        if (Faction::validateSolarSystemId($this->solarSystemId))  {
            return $this->solarSystemId; /*int*/
        }
        throw new Exception('never get to this Faction::solarSystemId');
    }

    /**
     * @param int
     * @return bool
     * @throws Exception
     */
    public static function validateSolarSystemId(int $value): bool {
        if (!is_integer($value)) {
            throw new Exception("Attribute Error:Faction::solarSystemId");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return int
     */
    public function getSolarSystemId(): int {
        if (Faction::validateSolarSystemId($this->solarSystemId))  {
            return $this->solarSystemId;
        }
        throw new Exception('never get to getSolarSystemId Faction::solarSystemId');
    }

    /**
     * @return int
     */
    public static function sampleSolarSystemId(): int {
        return 42; /*42:solarSystemId*/
    }

    /**
     * @param bool $value
     * @throws Exception
     * @return bool
     */
    public static function fromUniqueName(bool $value): bool {
        return $value; /*bool*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function toUniqueName(): bool {
        if (Faction::validateUniqueName($this->uniqueName))  {
            return $this->uniqueName; /*bool*/
        }
        throw new Exception('never get to this Faction::uniqueName');
    }

    /**
     * @param bool
     * @return bool
     * @throws Exception
     */
    public static function validateUniqueName(bool $value): bool {
        if (!is_bool($value)) {
            throw new Exception("Attribute Error:Faction::uniqueName");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function getUniqueName(): bool {
        if (Faction::validateUniqueName($this->uniqueName))  {
            return $this->uniqueName;
        }
        throw new Exception('never get to getUniqueName Faction::uniqueName');
    }

    /**
     * @return bool
     */
    public static function sampleUniqueName(): bool {
        return true; /*43:uniqueName*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return Faction::validateKey($this->key)
        || Faction::validateCorporationId($this->corporationId)
        || Faction::validateDescription($this->description)
        || Faction::validateFlatLogo($this->flatLogo)
        || Faction::validateFlatLogoWithName($this->flatLogoWithName)
        || Faction::validateIconId($this->iconId)
        || Faction::validateMemberRaces($this->memberRaces)
        || Faction::validateMilitiaCorporationId($this->militiaCorporationId)
        || Faction::validateName($this->name)
        || Faction::validateShortDescription($this->shortDescription)
        || Faction::validateSizeFactor($this->sizeFactor)
        || Faction::validateSolarSystemId($this->solarSystemId)
        || Faction::validateUniqueName($this->uniqueName);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'_key'} = $this->toKey();
        $out->{'corporationID'} = $this->toCorporationId();
        $out->{'description'} = $this->toDescription();
        $out->{'flatLogo'} = $this->toFlatLogo();
        $out->{'flatLogoWithName'} = $this->toFlatLogoWithName();
        $out->{'iconID'} = $this->toIconId();
        $out->{'memberRaces'} = $this->toMemberRaces();
        $out->{'militiaCorporationID'} = $this->toMilitiaCorporationId();
        $out->{'name'} = $this->toName();
        $out->{'shortDescription'} = $this->toShortDescription();
        $out->{'sizeFactor'} = $this->toSizeFactor();
        $out->{'solarSystemID'} = $this->toSolarSystemId();
        $out->{'uniqueName'} = $this->toUniqueName();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return Faction
     * @throws Exception
     */
    public static function from(stdClass $obj): Faction {
        return new Faction(
         Faction::fromKey($obj->{'_key'})
        ,Faction::fromCorporationId($obj->{'corporationID'})
        ,Faction::fromDescription($obj->{'description'})
        ,Faction::fromFlatLogo($obj->{'flatLogo'})
        ,Faction::fromFlatLogoWithName($obj->{'flatLogoWithName'})
        ,Faction::fromIconId($obj->{'iconID'})
        ,Faction::fromMemberRaces($obj->{'memberRaces'})
        ,Faction::fromMilitiaCorporationId($obj->{'militiaCorporationID'})
        ,Faction::fromName($obj->{'name'})
        ,Faction::fromShortDescription($obj->{'shortDescription'})
        ,Faction::fromSizeFactor($obj->{'sizeFactor'})
        ,Faction::fromSolarSystemId($obj->{'solarSystemID'})
        ,Faction::fromUniqueName($obj->{'uniqueName'})
        );
    }

    /**
     * @return Faction
     */
    public static function sample(): Faction {
        return new Faction(
         Faction::sampleKey()
        ,Faction::sampleCorporationId()
        ,Faction::sampleDescription()
        ,Faction::sampleFlatLogo()
        ,Faction::sampleFlatLogoWithName()
        ,Faction::sampleIconId()
        ,Faction::sampleMemberRaces()
        ,Faction::sampleMilitiaCorporationId()
        ,Faction::sampleName()
        ,Faction::sampleShortDescription()
        ,Faction::sampleSizeFactor()
        ,Faction::sampleSolarSystemId()
        ,Faction::sampleUniqueName()
        );
    }
}

// This is a autogenerated file:Description

class Description {
    private string $de; // json:de Required
    private string $en; // json:en Required
    private string $es; // json:es Required
    private string $fr; // json:fr Required
    private string $ja; // json:ja Required
    private string $ko; // json:ko Required
    private string $ru; // json:ru Required
    private string $zh; // json:zh Required

    /**
     * @param string $de
     * @param string $en
     * @param string $es
     * @param string $fr
     * @param string $ja
     * @param string $ko
     * @param string $ru
     * @param string $zh
     */
    public function __construct(string $de, string $en, string $es, string $fr, string $ja, string $ko, string $ru, string $zh) {
        $this->de = $de;
        $this->en = $en;
        $this->es = $es;
        $this->fr = $fr;
        $this->ja = $ja;
        $this->ko = $ko;
        $this->ru = $ru;
        $this->zh = $zh;
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromDe(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toDe(): string {
        if (Description::validateDe($this->de))  {
            return $this->de; /*string*/
        }
        throw new Exception('never get to this Description::de');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateDe(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Description::de");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getDe(): string {
        if (Description::validateDe($this->de))  {
            return $this->de;
        }
        throw new Exception('never get to getDe Description::de');
    }

    /**
     * @return string
     */
    public static function sampleDe(): string {
        return 'Description::de::31'; /*31:de*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromEn(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toEn(): string {
        if (Description::validateEn($this->en))  {
            return $this->en; /*string*/
        }
        throw new Exception('never get to this Description::en');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateEn(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Description::en");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getEn(): string {
        if (Description::validateEn($this->en))  {
            return $this->en;
        }
        throw new Exception('never get to getEn Description::en');
    }

    /**
     * @return string
     */
    public static function sampleEn(): string {
        return 'Description::en::32'; /*32:en*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromEs(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toEs(): string {
        if (Description::validateEs($this->es))  {
            return $this->es; /*string*/
        }
        throw new Exception('never get to this Description::es');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateEs(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Description::es");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getEs(): string {
        if (Description::validateEs($this->es))  {
            return $this->es;
        }
        throw new Exception('never get to getEs Description::es');
    }

    /**
     * @return string
     */
    public static function sampleEs(): string {
        return 'Description::es::33'; /*33:es*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromFr(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toFr(): string {
        if (Description::validateFr($this->fr))  {
            return $this->fr; /*string*/
        }
        throw new Exception('never get to this Description::fr');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateFr(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Description::fr");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getFr(): string {
        if (Description::validateFr($this->fr))  {
            return $this->fr;
        }
        throw new Exception('never get to getFr Description::fr');
    }

    /**
     * @return string
     */
    public static function sampleFr(): string {
        return 'Description::fr::34'; /*34:fr*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromJa(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toJa(): string {
        if (Description::validateJa($this->ja))  {
            return $this->ja; /*string*/
        }
        throw new Exception('never get to this Description::ja');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateJa(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Description::ja");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getJa(): string {
        if (Description::validateJa($this->ja))  {
            return $this->ja;
        }
        throw new Exception('never get to getJa Description::ja');
    }

    /**
     * @return string
     */
    public static function sampleJa(): string {
        return 'Description::ja::35'; /*35:ja*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromKo(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toKo(): string {
        if (Description::validateKo($this->ko))  {
            return $this->ko; /*string*/
        }
        throw new Exception('never get to this Description::ko');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateKo(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Description::ko");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getKo(): string {
        if (Description::validateKo($this->ko))  {
            return $this->ko;
        }
        throw new Exception('never get to getKo Description::ko');
    }

    /**
     * @return string
     */
    public static function sampleKo(): string {
        return 'Description::ko::36'; /*36:ko*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromRu(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toRu(): string {
        if (Description::validateRu($this->ru))  {
            return $this->ru; /*string*/
        }
        throw new Exception('never get to this Description::ru');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateRu(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Description::ru");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getRu(): string {
        if (Description::validateRu($this->ru))  {
            return $this->ru;
        }
        throw new Exception('never get to getRu Description::ru');
    }

    /**
     * @return string
     */
    public static function sampleRu(): string {
        return 'Description::ru::37'; /*37:ru*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromZh(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toZh(): string {
        if (Description::validateZh($this->zh))  {
            return $this->zh; /*string*/
        }
        throw new Exception('never get to this Description::zh');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateZh(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Description::zh");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getZh(): string {
        if (Description::validateZh($this->zh))  {
            return $this->zh;
        }
        throw new Exception('never get to getZh Description::zh');
    }

    /**
     * @return string
     */
    public static function sampleZh(): string {
        return 'Description::zh::38'; /*38:zh*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return Description::validateDe($this->de)
        || Description::validateEn($this->en)
        || Description::validateEs($this->es)
        || Description::validateFr($this->fr)
        || Description::validateJa($this->ja)
        || Description::validateKo($this->ko)
        || Description::validateRu($this->ru)
        || Description::validateZh($this->zh);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'de'} = $this->toDe();
        $out->{'en'} = $this->toEn();
        $out->{'es'} = $this->toEs();
        $out->{'fr'} = $this->toFr();
        $out->{'ja'} = $this->toJa();
        $out->{'ko'} = $this->toKo();
        $out->{'ru'} = $this->toRu();
        $out->{'zh'} = $this->toZh();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return Description
     * @throws Exception
     */
    public static function from(stdClass $obj): Description {
        return new Description(
         Description::fromDe($obj->{'de'})
        ,Description::fromEn($obj->{'en'})
        ,Description::fromEs($obj->{'es'})
        ,Description::fromFr($obj->{'fr'})
        ,Description::fromJa($obj->{'ja'})
        ,Description::fromKo($obj->{'ko'})
        ,Description::fromRu($obj->{'ru'})
        ,Description::fromZh($obj->{'zh'})
        );
    }

    /**
     * @return Description
     */
    public static function sample(): Description {
        return new Description(
         Description::sampleDe()
        ,Description::sampleEn()
        ,Description::sampleEs()
        ,Description::sampleFr()
        ,Description::sampleJa()
        ,Description::sampleKo()
        ,Description::sampleRu()
        ,Description::sampleZh()
        );
    }
}

// This is a autogenerated file:Name

class Name {
    private string $de; // json:de Required
    private string $en; // json:en Required
    private string $es; // json:es Required
    private string $fr; // json:fr Required
    private string $ja; // json:ja Required
    private string $ko; // json:ko Required
    private string $ru; // json:ru Required
    private string $zh; // json:zh Required

    /**
     * @param string $de
     * @param string $en
     * @param string $es
     * @param string $fr
     * @param string $ja
     * @param string $ko
     * @param string $ru
     * @param string $zh
     */
    public function __construct(string $de, string $en, string $es, string $fr, string $ja, string $ko, string $ru, string $zh) {
        $this->de = $de;
        $this->en = $en;
        $this->es = $es;
        $this->fr = $fr;
        $this->ja = $ja;
        $this->ko = $ko;
        $this->ru = $ru;
        $this->zh = $zh;
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromDe(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toDe(): string {
        if (Name::validateDe($this->de))  {
            return $this->de; /*string*/
        }
        throw new Exception('never get to this Name::de');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateDe(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Name::de");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getDe(): string {
        if (Name::validateDe($this->de))  {
            return $this->de;
        }
        throw new Exception('never get to getDe Name::de');
    }

    /**
     * @return string
     */
    public static function sampleDe(): string {
        return 'Name::de::31'; /*31:de*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromEn(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toEn(): string {
        if (Name::validateEn($this->en))  {
            return $this->en; /*string*/
        }
        throw new Exception('never get to this Name::en');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateEn(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Name::en");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getEn(): string {
        if (Name::validateEn($this->en))  {
            return $this->en;
        }
        throw new Exception('never get to getEn Name::en');
    }

    /**
     * @return string
     */
    public static function sampleEn(): string {
        return 'Name::en::32'; /*32:en*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromEs(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toEs(): string {
        if (Name::validateEs($this->es))  {
            return $this->es; /*string*/
        }
        throw new Exception('never get to this Name::es');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateEs(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Name::es");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getEs(): string {
        if (Name::validateEs($this->es))  {
            return $this->es;
        }
        throw new Exception('never get to getEs Name::es');
    }

    /**
     * @return string
     */
    public static function sampleEs(): string {
        return 'Name::es::33'; /*33:es*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromFr(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toFr(): string {
        if (Name::validateFr($this->fr))  {
            return $this->fr; /*string*/
        }
        throw new Exception('never get to this Name::fr');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateFr(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Name::fr");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getFr(): string {
        if (Name::validateFr($this->fr))  {
            return $this->fr;
        }
        throw new Exception('never get to getFr Name::fr');
    }

    /**
     * @return string
     */
    public static function sampleFr(): string {
        return 'Name::fr::34'; /*34:fr*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromJa(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toJa(): string {
        if (Name::validateJa($this->ja))  {
            return $this->ja; /*string*/
        }
        throw new Exception('never get to this Name::ja');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateJa(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Name::ja");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getJa(): string {
        if (Name::validateJa($this->ja))  {
            return $this->ja;
        }
        throw new Exception('never get to getJa Name::ja');
    }

    /**
     * @return string
     */
    public static function sampleJa(): string {
        return 'Name::ja::35'; /*35:ja*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromKo(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toKo(): string {
        if (Name::validateKo($this->ko))  {
            return $this->ko; /*string*/
        }
        throw new Exception('never get to this Name::ko');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateKo(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Name::ko");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getKo(): string {
        if (Name::validateKo($this->ko))  {
            return $this->ko;
        }
        throw new Exception('never get to getKo Name::ko');
    }

    /**
     * @return string
     */
    public static function sampleKo(): string {
        return 'Name::ko::36'; /*36:ko*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromRu(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toRu(): string {
        if (Name::validateRu($this->ru))  {
            return $this->ru; /*string*/
        }
        throw new Exception('never get to this Name::ru');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateRu(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Name::ru");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getRu(): string {
        if (Name::validateRu($this->ru))  {
            return $this->ru;
        }
        throw new Exception('never get to getRu Name::ru');
    }

    /**
     * @return string
     */
    public static function sampleRu(): string {
        return 'Name::ru::37'; /*37:ru*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromZh(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toZh(): string {
        if (Name::validateZh($this->zh))  {
            return $this->zh; /*string*/
        }
        throw new Exception('never get to this Name::zh');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateZh(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:Name::zh");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getZh(): string {
        if (Name::validateZh($this->zh))  {
            return $this->zh;
        }
        throw new Exception('never get to getZh Name::zh');
    }

    /**
     * @return string
     */
    public static function sampleZh(): string {
        return 'Name::zh::38'; /*38:zh*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return Name::validateDe($this->de)
        || Name::validateEn($this->en)
        || Name::validateEs($this->es)
        || Name::validateFr($this->fr)
        || Name::validateJa($this->ja)
        || Name::validateKo($this->ko)
        || Name::validateRu($this->ru)
        || Name::validateZh($this->zh);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'de'} = $this->toDe();
        $out->{'en'} = $this->toEn();
        $out->{'es'} = $this->toEs();
        $out->{'fr'} = $this->toFr();
        $out->{'ja'} = $this->toJa();
        $out->{'ko'} = $this->toKo();
        $out->{'ru'} = $this->toRu();
        $out->{'zh'} = $this->toZh();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return Name
     * @throws Exception
     */
    public static function from(stdClass $obj): Name {
        return new Name(
         Name::fromDe($obj->{'de'})
        ,Name::fromEn($obj->{'en'})
        ,Name::fromEs($obj->{'es'})
        ,Name::fromFr($obj->{'fr'})
        ,Name::fromJa($obj->{'ja'})
        ,Name::fromKo($obj->{'ko'})
        ,Name::fromRu($obj->{'ru'})
        ,Name::fromZh($obj->{'zh'})
        );
    }

    /**
     * @return Name
     */
    public static function sample(): Name {
        return new Name(
         Name::sampleDe()
        ,Name::sampleEn()
        ,Name::sampleEs()
        ,Name::sampleFr()
        ,Name::sampleJa()
        ,Name::sampleKo()
        ,Name::sampleRu()
        ,Name::sampleZh()
        );
    }
}

// This is a autogenerated file:ShortDescription

class ShortDescription {
    private string $de; // json:de Required
    private string $en; // json:en Required
    private string $es; // json:es Required
    private string $fr; // json:fr Required
    private string $ja; // json:ja Required
    private string $ko; // json:ko Required
    private string $ru; // json:ru Required
    private string $zh; // json:zh Required

    /**
     * @param string $de
     * @param string $en
     * @param string $es
     * @param string $fr
     * @param string $ja
     * @param string $ko
     * @param string $ru
     * @param string $zh
     */
    public function __construct(string $de, string $en, string $es, string $fr, string $ja, string $ko, string $ru, string $zh) {
        $this->de = $de;
        $this->en = $en;
        $this->es = $es;
        $this->fr = $fr;
        $this->ja = $ja;
        $this->ko = $ko;
        $this->ru = $ru;
        $this->zh = $zh;
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromDe(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toDe(): string {
        if (ShortDescription::validateDe($this->de))  {
            return $this->de; /*string*/
        }
        throw new Exception('never get to this ShortDescription::de');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateDe(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:ShortDescription::de");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getDe(): string {
        if (ShortDescription::validateDe($this->de))  {
            return $this->de;
        }
        throw new Exception('never get to getDe ShortDescription::de');
    }

    /**
     * @return string
     */
    public static function sampleDe(): string {
        return 'ShortDescription::de::31'; /*31:de*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromEn(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toEn(): string {
        if (ShortDescription::validateEn($this->en))  {
            return $this->en; /*string*/
        }
        throw new Exception('never get to this ShortDescription::en');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateEn(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:ShortDescription::en");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getEn(): string {
        if (ShortDescription::validateEn($this->en))  {
            return $this->en;
        }
        throw new Exception('never get to getEn ShortDescription::en');
    }

    /**
     * @return string
     */
    public static function sampleEn(): string {
        return 'ShortDescription::en::32'; /*32:en*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromEs(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toEs(): string {
        if (ShortDescription::validateEs($this->es))  {
            return $this->es; /*string*/
        }
        throw new Exception('never get to this ShortDescription::es');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateEs(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:ShortDescription::es");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getEs(): string {
        if (ShortDescription::validateEs($this->es))  {
            return $this->es;
        }
        throw new Exception('never get to getEs ShortDescription::es');
    }

    /**
     * @return string
     */
    public static function sampleEs(): string {
        return 'ShortDescription::es::33'; /*33:es*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromFr(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toFr(): string {
        if (ShortDescription::validateFr($this->fr))  {
            return $this->fr; /*string*/
        }
        throw new Exception('never get to this ShortDescription::fr');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateFr(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:ShortDescription::fr");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getFr(): string {
        if (ShortDescription::validateFr($this->fr))  {
            return $this->fr;
        }
        throw new Exception('never get to getFr ShortDescription::fr');
    }

    /**
     * @return string
     */
    public static function sampleFr(): string {
        return 'ShortDescription::fr::34'; /*34:fr*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromJa(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toJa(): string {
        if (ShortDescription::validateJa($this->ja))  {
            return $this->ja; /*string*/
        }
        throw new Exception('never get to this ShortDescription::ja');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateJa(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:ShortDescription::ja");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getJa(): string {
        if (ShortDescription::validateJa($this->ja))  {
            return $this->ja;
        }
        throw new Exception('never get to getJa ShortDescription::ja');
    }

    /**
     * @return string
     */
    public static function sampleJa(): string {
        return 'ShortDescription::ja::35'; /*35:ja*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromKo(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toKo(): string {
        if (ShortDescription::validateKo($this->ko))  {
            return $this->ko; /*string*/
        }
        throw new Exception('never get to this ShortDescription::ko');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateKo(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:ShortDescription::ko");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getKo(): string {
        if (ShortDescription::validateKo($this->ko))  {
            return $this->ko;
        }
        throw new Exception('never get to getKo ShortDescription::ko');
    }

    /**
     * @return string
     */
    public static function sampleKo(): string {
        return 'ShortDescription::ko::36'; /*36:ko*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromRu(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toRu(): string {
        if (ShortDescription::validateRu($this->ru))  {
            return $this->ru; /*string*/
        }
        throw new Exception('never get to this ShortDescription::ru');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateRu(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:ShortDescription::ru");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getRu(): string {
        if (ShortDescription::validateRu($this->ru))  {
            return $this->ru;
        }
        throw new Exception('never get to getRu ShortDescription::ru');
    }

    /**
     * @return string
     */
    public static function sampleRu(): string {
        return 'ShortDescription::ru::37'; /*37:ru*/
    }

    /**
     * @param string $value
     * @throws Exception
     * @return string
     */
    public static function fromZh(string $value): string {
        return $value; /*string*/
    }

    /**
     * @throws Exception
     * @return string
     */
    public function toZh(): string {
        if (ShortDescription::validateZh($this->zh))  {
            return $this->zh; /*string*/
        }
        throw new Exception('never get to this ShortDescription::zh');
    }

    /**
     * @param string
     * @return bool
     * @throws Exception
     */
    public static function validateZh(string $value): bool {
        if (!is_string($value)) {
            throw new Exception("Attribute Error:ShortDescription::zh");
        }
        return true;
    }

    /**
     * @throws Exception
     * @return string
     */
    public function getZh(): string {
        if (ShortDescription::validateZh($this->zh))  {
            return $this->zh;
        }
        throw new Exception('never get to getZh ShortDescription::zh');
    }

    /**
     * @return string
     */
    public static function sampleZh(): string {
        return 'ShortDescription::zh::38'; /*38:zh*/
    }

    /**
     * @throws Exception
     * @return bool
     */
    public function validate(): bool {
        return ShortDescription::validateDe($this->de)
        || ShortDescription::validateEn($this->en)
        || ShortDescription::validateEs($this->es)
        || ShortDescription::validateFr($this->fr)
        || ShortDescription::validateJa($this->ja)
        || ShortDescription::validateKo($this->ko)
        || ShortDescription::validateRu($this->ru)
        || ShortDescription::validateZh($this->zh);
    }

    /**
     * @return stdClass
     * @throws Exception
     */
    public function to(): stdClass  {
        $out = new stdClass();
        $out->{'de'} = $this->toDe();
        $out->{'en'} = $this->toEn();
        $out->{'es'} = $this->toEs();
        $out->{'fr'} = $this->toFr();
        $out->{'ja'} = $this->toJa();
        $out->{'ko'} = $this->toKo();
        $out->{'ru'} = $this->toRu();
        $out->{'zh'} = $this->toZh();
        return $out;
    }

    /**
     * @param stdClass $obj
     * @return ShortDescription
     * @throws Exception
     */
    public static function from(stdClass $obj): ShortDescription {
        return new ShortDescription(
         ShortDescription::fromDe($obj->{'de'})
        ,ShortDescription::fromEn($obj->{'en'})
        ,ShortDescription::fromEs($obj->{'es'})
        ,ShortDescription::fromFr($obj->{'fr'})
        ,ShortDescription::fromJa($obj->{'ja'})
        ,ShortDescription::fromKo($obj->{'ko'})
        ,ShortDescription::fromRu($obj->{'ru'})
        ,ShortDescription::fromZh($obj->{'zh'})
        );
    }

    /**
     * @return ShortDescription
     */
    public static function sample(): ShortDescription {
        return new ShortDescription(
         ShortDescription::sampleDe()
        ,ShortDescription::sampleEn()
        ,ShortDescription::sampleEs()
        ,ShortDescription::sampleFr()
        ,ShortDescription::sampleJa()
        ,ShortDescription::sampleKo()
        ,ShortDescription::sampleRu()
        ,ShortDescription::sampleZh()
        );
    }
}
from typing import Any, Optional, List, TypeVar, Callable, Type, cast


T = TypeVar("T")


def from_str(x: Any) -> str:
    assert isinstance(x, str)
    return x


def from_int(x: Any) -> int:
    assert isinstance(x, int) and not isinstance(x, bool)
    return x


def from_none(x: Any) -> Any:
    assert x is None
    return x


def from_union(fs, x):
    for f in fs:
        try:
            return f(x)
        except:
            pass
    assert False


def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
    assert isinstance(x, list)
    return [f(y) for y in x]


def from_float(x: Any) -> float:
    assert isinstance(x, (float, int)) and not isinstance(x, bool)
    return float(x)


def from_bool(x: Any) -> bool:
    assert isinstance(x, bool)
    return x


def to_class(c: Type[T], x: Any) -> dict:
    assert isinstance(x, c)
    return cast(Any, x).to_dict()


def to_float(x: Any) -> float:
    assert isinstance(x, (int, float))
    return x


class Description:
    de: str
    en: str
    es: str
    fr: str
    ja: str
    ko: str
    ru: str
    zh: str

    def __init__(self, de: str, en: str, es: str, fr: str, ja: str, ko: str, ru: str, zh: str) -> None:
        self.de = de
        self.en = en
        self.es = es
        self.fr = fr
        self.ja = ja
        self.ko = ko
        self.ru = ru
        self.zh = zh

    @staticmethod
    def from_dict(obj: Any) -> 'Description':
        assert isinstance(obj, dict)
        de = from_str(obj.get("de"))
        en = from_str(obj.get("en"))
        es = from_str(obj.get("es"))
        fr = from_str(obj.get("fr"))
        ja = from_str(obj.get("ja"))
        ko = from_str(obj.get("ko"))
        ru = from_str(obj.get("ru"))
        zh = from_str(obj.get("zh"))
        return Description(de, en, es, fr, ja, ko, ru, zh)

    def to_dict(self) -> dict:
        result: dict = {}
        result["de"] = from_str(self.de)
        result["en"] = from_str(self.en)
        result["es"] = from_str(self.es)
        result["fr"] = from_str(self.fr)
        result["ja"] = from_str(self.ja)
        result["ko"] = from_str(self.ko)
        result["ru"] = from_str(self.ru)
        result["zh"] = from_str(self.zh)
        return result


class Name:
    de: str
    en: str
    es: str
    fr: str
    ja: str
    ko: str
    ru: str
    zh: str

    def __init__(self, de: str, en: str, es: str, fr: str, ja: str, ko: str, ru: str, zh: str) -> None:
        self.de = de
        self.en = en
        self.es = es
        self.fr = fr
        self.ja = ja
        self.ko = ko
        self.ru = ru
        self.zh = zh

    @staticmethod
    def from_dict(obj: Any) -> 'Name':
        assert isinstance(obj, dict)
        de = from_str(obj.get("de"))
        en = from_str(obj.get("en"))
        es = from_str(obj.get("es"))
        fr = from_str(obj.get("fr"))
        ja = from_str(obj.get("ja"))
        ko = from_str(obj.get("ko"))
        ru = from_str(obj.get("ru"))
        zh = from_str(obj.get("zh"))
        return Name(de, en, es, fr, ja, ko, ru, zh)

    def to_dict(self) -> dict:
        result: dict = {}
        result["de"] = from_str(self.de)
        result["en"] = from_str(self.en)
        result["es"] = from_str(self.es)
        result["fr"] = from_str(self.fr)
        result["ja"] = from_str(self.ja)
        result["ko"] = from_str(self.ko)
        result["ru"] = from_str(self.ru)
        result["zh"] = from_str(self.zh)
        return result


class ShortDescription:
    de: str
    en: str
    es: str
    fr: str
    ja: str
    ko: str
    ru: str
    zh: str

    def __init__(self, de: str, en: str, es: str, fr: str, ja: str, ko: str, ru: str, zh: str) -> None:
        self.de = de
        self.en = en
        self.es = es
        self.fr = fr
        self.ja = ja
        self.ko = ko
        self.ru = ru
        self.zh = zh

    @staticmethod
    def from_dict(obj: Any) -> 'ShortDescription':
        assert isinstance(obj, dict)
        de = from_str(obj.get("de"))
        en = from_str(obj.get("en"))
        es = from_str(obj.get("es"))
        fr = from_str(obj.get("fr"))
        ja = from_str(obj.get("ja"))
        ko = from_str(obj.get("ko"))
        ru = from_str(obj.get("ru"))
        zh = from_str(obj.get("zh"))
        return ShortDescription(de, en, es, fr, ja, ko, ru, zh)

    def to_dict(self) -> dict:
        result: dict = {}
        result["de"] = from_str(self.de)
        result["en"] = from_str(self.en)
        result["es"] = from_str(self.es)
        result["fr"] = from_str(self.fr)
        result["ja"] = from_str(self.ja)
        result["ko"] = from_str(self.ko)
        result["ru"] = from_str(self.ru)
        result["zh"] = from_str(self.zh)
        return result


class Faction:
    key: int
    corporation_id: Optional[int]
    description: Description
    flat_logo: Optional[str]
    flat_logo_with_name: Optional[str]
    icon_id: int
    member_races: List[int]
    militia_corporation_id: Optional[int]
    name: Name
    short_description: Optional[ShortDescription]
    size_factor: float
    solar_system_id: int
    unique_name: bool

    def __init__(self, key: int, corporation_id: Optional[int], description: Description, flat_logo: Optional[str], flat_logo_with_name: Optional[str], icon_id: int, member_races: List[int], militia_corporation_id: Optional[int], name: Name, short_description: Optional[ShortDescription], size_factor: float, solar_system_id: int, unique_name: bool) -> None:
        self.key = key
        self.corporation_id = corporation_id
        self.description = description
        self.flat_logo = flat_logo
        self.flat_logo_with_name = flat_logo_with_name
        self.icon_id = icon_id
        self.member_races = member_races
        self.militia_corporation_id = militia_corporation_id
        self.name = name
        self.short_description = short_description
        self.size_factor = size_factor
        self.solar_system_id = solar_system_id
        self.unique_name = unique_name

    @staticmethod
    def from_dict(obj: Any) -> 'Faction':
        assert isinstance(obj, dict)
        key = from_int(obj.get("_key"))
        corporation_id = from_union([from_int, from_none], obj.get("corporationID"))
        description = Description.from_dict(obj.get("description"))
        flat_logo = from_union([from_str, from_none], obj.get("flatLogo"))
        flat_logo_with_name = from_union([from_str, from_none], obj.get("flatLogoWithName"))
        icon_id = from_int(obj.get("iconID"))
        member_races = from_list(from_int, obj.get("memberRaces"))
        militia_corporation_id = from_union([from_int, from_none], obj.get("militiaCorporationID"))
        name = Name.from_dict(obj.get("name"))
        short_description = from_union([ShortDescription.from_dict, from_none], obj.get("shortDescription"))
        size_factor = from_float(obj.get("sizeFactor"))
        solar_system_id = from_int(obj.get("solarSystemID"))
        unique_name = from_bool(obj.get("uniqueName"))
        return Faction(key, corporation_id, description, flat_logo, flat_logo_with_name, icon_id, member_races, militia_corporation_id, name, short_description, size_factor, solar_system_id, unique_name)

    def to_dict(self) -> dict:
        result: dict = {}
        result["_key"] = from_int(self.key)
        if self.corporation_id is not None:
            result["corporationID"] = from_union([from_int, from_none], self.corporation_id)
        result["description"] = to_class(Description, self.description)
        if self.flat_logo is not None:
            result["flatLogo"] = from_union([from_str, from_none], self.flat_logo)
        if self.flat_logo_with_name is not None:
            result["flatLogoWithName"] = from_union([from_str, from_none], self.flat_logo_with_name)
        result["iconID"] = from_int(self.icon_id)
        result["memberRaces"] = from_list(from_int, self.member_races)
        if self.militia_corporation_id is not None:
            result["militiaCorporationID"] = from_union([from_int, from_none], self.militia_corporation_id)
        result["name"] = to_class(Name, self.name)
        if self.short_description is not None:
            result["shortDescription"] = from_union([lambda x: to_class(ShortDescription, x), from_none], self.short_description)
        result["sizeFactor"] = to_float(self.size_factor)
        result["solarSystemID"] = from_int(self.solar_system_id)
        result["uniqueName"] = from_bool(self.unique_name)
        return result


def faction_from_dict(s: Any) -> Faction:
    return Faction.from_dict(s)


def faction_to_dict(x: Faction) -> Any:
    return to_class(Faction, x)
// To parse this data:
//
//   import { Convert, Faction } from "./file";
//
//   const faction = Convert.toFaction(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.

export interface Faction {
    _key:                  number;
    corporationID?:        number;
    description:           Description;
    flatLogo?:             string;
    flatLogoWithName?:     string;
    iconID:                number;
    memberRaces:           number[];
    militiaCorporationID?: number;
    name:                  Name;
    shortDescription?:     ShortDescription;
    sizeFactor:            number;
    solarSystemID:         number;
    uniqueName:            boolean;
    [property: string]: any;
}

export interface Description {
    de: string;
    en: string;
    es: string;
    fr: string;
    ja: string;
    ko: string;
    ru: string;
    zh: string;
    [property: string]: any;
}

export interface Name {
    de: string;
    en: string;
    es: string;
    fr: string;
    ja: string;
    ko: string;
    ru: string;
    zh: string;
    [property: string]: any;
}

export interface ShortDescription {
    de: string;
    en: string;
    es: string;
    fr: string;
    ja: string;
    ko: string;
    ru: string;
    zh: string;
    [property: string]: any;
}

// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
    public static toFaction(json: string): Faction {
        return cast(JSON.parse(json), r("Faction"));
    }

    public static factionToJson(value: Faction): string {
        return JSON.stringify(uncast(value, r("Faction")), null, 2);
    }
}

function invalidValue(typ: any, val: any, key: any, parent: any = ''): never {
    const prettyTyp = prettyTypeName(typ);
    const parentText = parent ? ` on ${parent}` : '';
    const keyText = key ? ` for key "${key}"` : '';
    throw Error(`Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}`);
}

function prettyTypeName(typ: any): string {
    if (Array.isArray(typ)) {
        if (typ.length === 2 && typ[0] === undefined) {
            return `an optional ${prettyTypeName(typ[1])}`;
        } else {
            return `one of [${typ.map(a => { return prettyTypeName(a); }).join(", ")}]`;
        }
    } else if (typeof typ === "object" && typ.literal !== undefined) {
        return typ.literal;
    } else {
        return typeof typ;
    }
}

function jsonToJSProps(typ: any): any {
    if (typ.jsonToJS === undefined) {
        const map: any = {};
        typ.props.forEach((p: any) => map[p.json] = { key: p.js, typ: p.typ });
        typ.jsonToJS = map;
    }
    return typ.jsonToJS;
}

function jsToJSONProps(typ: any): any {
    if (typ.jsToJSON === undefined) {
        const map: any = {};
        typ.props.forEach((p: any) => map[p.js] = { key: p.json, typ: p.typ });
        typ.jsToJSON = map;
    }
    return typ.jsToJSON;
}

function transform(val: any, typ: any, getProps: any, key: any = '', parent: any = ''): any {
    function transformPrimitive(typ: string, val: any): any {
        if (typeof typ === typeof val) return val;
        return invalidValue(typ, val, key, parent);
    }

    function transformUnion(typs: any[], val: any): any {
        // val must validate against one typ in typs
        const l = typs.length;
        for (let i = 0; i < l; i++) {
            const typ = typs[i];
            try {
                return transform(val, typ, getProps);
            } catch (_) {}
        }
        return invalidValue(typs, val, key, parent);
    }

    function transformEnum(cases: string[], val: any): any {
        if (cases.indexOf(val) !== -1) return val;
        return invalidValue(cases.map(a => { return l(a); }), val, key, parent);
    }

    function transformArray(typ: any, val: any): any {
        // val must be an array with no invalid elements
        if (!Array.isArray(val)) return invalidValue(l("array"), val, key, parent);
        return val.map(el => transform(el, typ, getProps));
    }

    function transformDate(val: any): any {
        if (val === null) {
            return null;
        }
        const d = new Date(val);
        if (isNaN(d.valueOf())) {
            return invalidValue(l("Date"), val, key, parent);
        }
        return d;
    }

    function transformObject(props: { [k: string]: any }, additional: any, val: any): any {
        if (val === null || typeof val !== "object" || Array.isArray(val)) {
            return invalidValue(l(ref || "object"), val, key, parent);
        }
        const result: any = {};
        Object.getOwnPropertyNames(props).forEach(key => {
            const prop = props[key];
            const v = Object.prototype.hasOwnProperty.call(val, key) ? val[key] : undefined;
            result[prop.key] = transform(v, prop.typ, getProps, key, ref);
        });
        Object.getOwnPropertyNames(val).forEach(key => {
            if (!Object.prototype.hasOwnProperty.call(props, key)) {
                result[key] = transform(val[key], additional, getProps, key, ref);
            }
        });
        return result;
    }

    if (typ === "any") return val;
    if (typ === null) {
        if (val === null) return val;
        return invalidValue(typ, val, key, parent);
    }
    if (typ === false) return invalidValue(typ, val, key, parent);
    let ref: any = undefined;
    while (typeof typ === "object" && typ.ref !== undefined) {
        ref = typ.ref;
        typ = typeMap[typ.ref];
    }
    if (Array.isArray(typ)) return transformEnum(typ, val);
    if (typeof typ === "object") {
        return typ.hasOwnProperty("unionMembers") ? transformUnion(typ.unionMembers, val)
            : typ.hasOwnProperty("arrayItems")    ? transformArray(typ.arrayItems, val)
            : typ.hasOwnProperty("props")         ? transformObject(getProps(typ), typ.additional, val)
            : invalidValue(typ, val, key, parent);
    }
    // Numbers can be parsed by Date but shouldn't be.
    if (typ === Date && typeof val !== "number") return transformDate(val);
    return transformPrimitive(typ, val);
}

function cast<T>(val: any, typ: any): T {
    return transform(val, typ, jsonToJSProps);
}

function uncast<T>(val: T, typ: any): any {
    return transform(val, typ, jsToJSONProps);
}

function l(typ: any) {
    return { literal: typ };
}

function a(typ: any) {
    return { arrayItems: typ };
}

function u(...typs: any[]) {
    return { unionMembers: typs };
}

function o(props: any[], additional: any) {
    return { props, additional };
}

function m(additional: any) {
    return { props: [], additional };
}

function r(name: string) {
    return { ref: name };
}

const typeMap: any = {
    "Faction": o([
        { json: "_key", js: "_key", typ: 0 },
        { json: "corporationID", js: "corporationID", typ: u(undefined, 0) },
        { json: "description", js: "description", typ: r("Description") },
        { json: "flatLogo", js: "flatLogo", typ: u(undefined, "") },
        { json: "flatLogoWithName", js: "flatLogoWithName", typ: u(undefined, "") },
        { json: "iconID", js: "iconID", typ: 0 },
        { json: "memberRaces", js: "memberRaces", typ: a(0) },
        { json: "militiaCorporationID", js: "militiaCorporationID", typ: u(undefined, 0) },
        { json: "name", js: "name", typ: r("Name") },
        { json: "shortDescription", js: "shortDescription", typ: u(undefined, r("ShortDescription")) },
        { json: "sizeFactor", js: "sizeFactor", typ: 3.14 },
        { json: "solarSystemID", js: "solarSystemID", typ: 0 },
        { json: "uniqueName", js: "uniqueName", typ: true },
    ], "any"),
    "Description": o([
        { json: "de", js: "de", typ: "" },
        { json: "en", js: "en", typ: "" },
        { json: "es", js: "es", typ: "" },
        { json: "fr", js: "fr", typ: "" },
        { json: "ja", js: "ja", typ: "" },
        { json: "ko", js: "ko", typ: "" },
        { json: "ru", js: "ru", typ: "" },
        { json: "zh", js: "zh", typ: "" },
    ], "any"),
    "Name": o([
        { json: "de", js: "de", typ: "" },
        { json: "en", js: "en", typ: "" },
        { json: "es", js: "es", typ: "" },
        { json: "fr", js: "fr", typ: "" },
        { json: "ja", js: "ja", typ: "" },
        { json: "ko", js: "ko", typ: "" },
        { json: "ru", js: "ru", typ: "" },
        { json: "zh", js: "zh", typ: "" },
    ], "any"),
    "ShortDescription": o([
        { json: "de", js: "de", typ: "" },
        { json: "en", js: "en", typ: "" },
        { json: "es", js: "es", typ: "" },
        { json: "fr", js: "fr", typ: "" },
        { json: "ja", js: "ja", typ: "" },
        { json: "ko", js: "ko", typ: "" },
        { json: "ru", js: "ru", typ: "" },
        { json: "zh", js: "zh", typ: "" },
    ], "any"),
};