skins.jsonl
Schema
_key
(required): integer
Range: 5 .. 12585allowCCPDevs
(required): booleaninternalName
(required): stringisStructureSkin
: boolean-
skinDescription
: objectde
: stringen
(required): stringes
: stringfr
: stringja
: stringko
: stringru
: stringzh
: string
-
skinID
(required): integer
Range: 5 .. 12585 skinMaterialID
(required): integer
Range: 1 .. 3163types
(required): array of integer
Type:integer
Range: 582 .. 85236visibleSerenity
(required): booleanvisibleTranquility
(required): boolean
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var skin = Skin.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class Skin
{
[JsonProperty("_key")]
public long Key { get; set; }
[JsonProperty("allowCCPDevs")]
public bool AllowCcpDevs { get; set; }
[JsonProperty("internalName")]
[JsonConverter(typeof(PurpleMinMaxLengthCheckConverter))]
public string InternalName { get; set; }
[JsonProperty("isStructureSkin", NullValueHandling = NullValueHandling.Ignore)]
public bool? IsStructureSkin { get; set; }
[JsonProperty("skinDescription", NullValueHandling = NullValueHandling.Ignore)]
public SkinDescription SkinDescription { get; set; }
[JsonProperty("skinID")]
public long SkinId { get; set; }
[JsonProperty("skinMaterialID")]
public long SkinMaterialId { get; set; }
[JsonProperty("types")]
public long[] Types { get; set; }
[JsonProperty("visibleSerenity")]
public bool VisibleSerenity { get; set; }
[JsonProperty("visibleTranquility")]
public bool VisibleTranquility { get; set; }
}
public partial class SkinDescription
{
[JsonProperty("de", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(FluffyMinMaxLengthCheckConverter))]
public string De { get; set; }
[JsonProperty("en")]
[JsonConverter(typeof(TentacledMinMaxLengthCheckConverter))]
public string En { get; set; }
[JsonProperty("es", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(StickyMinMaxLengthCheckConverter))]
public string Es { get; set; }
[JsonProperty("fr", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(IndigoMinMaxLengthCheckConverter))]
public string Fr { get; set; }
[JsonProperty("ja", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(IndecentMinMaxLengthCheckConverter))]
public string Ja { get; set; }
[JsonProperty("ko", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(HilariousMinMaxLengthCheckConverter))]
public string Ko { get; set; }
[JsonProperty("ru", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(AmbitiousMinMaxLengthCheckConverter))]
public string Ru { get; set; }
[JsonProperty("zh", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(CunningMinMaxLengthCheckConverter))]
public string Zh { get; set; }
}
public partial class Skin
{
public static Skin FromJson(string json) => JsonConvert.DeserializeObject<Skin>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this Skin 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 >= 7 && value.Length <= 62)
{
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 <= 62)
{
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 >= 4 && value.Length <= 2303)
{
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 >= 4 && value.Length <= 2303)
{
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 >= 4 && value.Length <= 2043)
{
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 >= 4 && value.Length <= 2043)
{
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 >= 6 && value.Length <= 2399)
{
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 <= 2399)
{
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 >= 4 && value.Length <= 2523)
{
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 >= 4 && value.Length <= 2523)
{
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 >= 3 && value.Length <= 948)
{
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 <= 948)
{
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 >= 3 && value.Length <= 1506)
{
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 <= 1506)
{
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 >= 4 && value.Length <= 2154)
{
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 >= 4 && value.Length <= 2154)
{
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 >= 2 && value.Length <= 527)
{
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 <= 527)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly CunningMinMaxLengthCheckConverter Singleton = new CunningMinMaxLengthCheckConverter();
}
}
// 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:
//
// skin, err := UnmarshalSkin(bytes)
// bytes, err = skin.Marshal()
package model
import "encoding/json"
func UnmarshalSkin(data []byte) (Skin, error) {
var r Skin
err := json.Unmarshal(data, &r)
return r, err
}
func (r *Skin) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type Skin struct {
Key int64 `json:"_key"`
AllowCCPDevs bool `json:"allowCCPDevs"`
InternalName string `json:"internalName"`
IsStructureSkin *bool `json:"isStructureSkin,omitempty"`
SkinDescription *SkinDescription `json:"skinDescription,omitempty"`
SkinID int64 `json:"skinID"`
SkinMaterialID int64 `json:"skinMaterialID"`
Types []int64 `json:"types"`
VisibleSerenity bool `json:"visibleSerenity"`
VisibleTranquility bool `json:"visibleTranquility"`
}
type SkinDescription struct {
De *string `json:"de,omitempty"`
En string `json:"en"`
Es *string `json:"es,omitempty"`
Fr *string `json:"fr,omitempty"`
Ja *string `json:"ja,omitempty"`
Ko *string `json:"ko,omitempty"`
Ru *string `json:"ru,omitempty"`
Zh *string `json:"zh,omitempty"`
}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"_key": {
"type": "integer",
"minimum": 5,
"maximum": 12585
},
"allowCCPDevs": {
"type": "boolean"
},
"internalName": {
"type": "string",
"minLength": 7,
"maxLength": 62
},
"isStructureSkin": {
"type": "boolean"
},
"skinDescription": {
"type": "object",
"properties": {
"de": {
"type": "string",
"minLength": 4,
"maxLength": 2303
},
"en": {
"type": "string",
"minLength": 4,
"maxLength": 2043
},
"es": {
"type": "string",
"minLength": 6,
"maxLength": 2399
},
"fr": {
"type": "string",
"minLength": 4,
"maxLength": 2523
},
"ja": {
"type": "string",
"minLength": 3,
"maxLength": 948
},
"ko": {
"type": "string",
"minLength": 3,
"maxLength": 1506
},
"ru": {
"type": "string",
"minLength": 4,
"maxLength": 2154
},
"zh": {
"type": "string",
"minLength": 2,
"maxLength": 527
}
},
"required": [
"en"
]
},
"skinID": {
"type": "integer",
"minimum": 5,
"maximum": 12585
},
"skinMaterialID": {
"type": "integer",
"minimum": 1,
"maximum": 3163
},
"types": {
"type": "array",
"items": {
"type": "integer",
"minimum": 582,
"maximum": 85236
},
"minItems": 1,
"maxItems": 11
},
"visibleSerenity": {
"type": "boolean"
},
"visibleTranquility": {
"type": "boolean"
}
},
"required": [
"_key",
"allowCCPDevs",
"internalName",
"skinID",
"skinMaterialID",
"types",
"visibleSerenity",
"visibleTranquility"
]
}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val skin = json.parse(Skin.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class Skin (
@SerialName("_key")
val key: Long,
@SerialName("allowCCPDevs")
val allowCcpDevs: Boolean,
val internalName: String,
val isStructureSkin: Boolean? = null,
val skinDescription: SkinDescription? = null,
@SerialName("skinID")
val skinId: Long,
@SerialName("skinMaterialID")
val skinMaterialId: Long,
val types: List<Long>,
val visibleSerenity: Boolean,
val visibleTranquility: Boolean
)
@Serializable
data class SkinDescription (
val de: String? = null,
val en: String,
val es: String? = null,
val fr: String? = null,
val ja: String? = null,
val ko: String? = null,
val ru: String? = null,
val zh: String? = null
)
<?php
// This is a autogenerated file:Skin
class Skin {
private int $key; // json:_key Required
private bool $allowCcpDevs; // json:allowCCPDevs Required
private string $internalName; // json:internalName Required
private ?bool $isStructureSkin; // json:isStructureSkin Optional
private ?SkinDescription $skinDescription; // json:skinDescription Optional
private int $skinId; // json:skinID Required
private int $skinMaterialId; // json:skinMaterialID Required
private array $types; // json:types Required
private bool $visibleSerenity; // json:visibleSerenity Required
private bool $visibleTranquility; // json:visibleTranquility Required
/**
* @param int $key
* @param bool $allowCcpDevs
* @param string $internalName
* @param bool|null $isStructureSkin
* @param SkinDescription|null $skinDescription
* @param int $skinId
* @param int $skinMaterialId
* @param array $types
* @param bool $visibleSerenity
* @param bool $visibleTranquility
*/
public function __construct(int $key, bool $allowCcpDevs, string $internalName, ?bool $isStructureSkin, ?SkinDescription $skinDescription, int $skinId, int $skinMaterialId, array $types, bool $visibleSerenity, bool $visibleTranquility) {
$this->key = $key;
$this->allowCcpDevs = $allowCcpDevs;
$this->internalName = $internalName;
$this->isStructureSkin = $isStructureSkin;
$this->skinDescription = $skinDescription;
$this->skinId = $skinId;
$this->skinMaterialId = $skinMaterialId;
$this->types = $types;
$this->visibleSerenity = $visibleSerenity;
$this->visibleTranquility = $visibleTranquility;
}
/**
* @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 (Skin::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this Skin::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Skin::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (Skin::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey Skin::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param bool $value
* @throws Exception
* @return bool
*/
public static function fromAllowCcpDevs(bool $value): bool {
return $value; /*bool*/
}
/**
* @throws Exception
* @return bool
*/
public function toAllowCcpDevs(): bool {
if (Skin::validateAllowCcpDevs($this->allowCcpDevs)) {
return $this->allowCcpDevs; /*bool*/
}
throw new Exception('never get to this Skin::allowCcpDevs');
}
/**
* @param bool
* @return bool
* @throws Exception
*/
public static function validateAllowCcpDevs(bool $value): bool {
if (!is_bool($value)) {
throw new Exception("Attribute Error:Skin::allowCcpDevs");
}
return true;
}
/**
* @throws Exception
* @return bool
*/
public function getAllowCcpDevs(): bool {
if (Skin::validateAllowCcpDevs($this->allowCcpDevs)) {
return $this->allowCcpDevs;
}
throw new Exception('never get to getAllowCcpDevs Skin::allowCcpDevs');
}
/**
* @return bool
*/
public static function sampleAllowCcpDevs(): bool {
return true; /*32:allowCcpDevs*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromInternalName(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toInternalName(): string {
if (Skin::validateInternalName($this->internalName)) {
return $this->internalName; /*string*/
}
throw new Exception('never get to this Skin::internalName');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateInternalName(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:Skin::internalName");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getInternalName(): string {
if (Skin::validateInternalName($this->internalName)) {
return $this->internalName;
}
throw new Exception('never get to getInternalName Skin::internalName');
}
/**
* @return string
*/
public static function sampleInternalName(): string {
return 'Skin::internalName::33'; /*33:internalName*/
}
/**
* @param ?bool $value
* @throws Exception
* @return ?bool
*/
public static function fromIsStructureSkin(?bool $value): ?bool {
if (!is_null($value)) {
return $value; /*bool*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?bool
*/
public function toIsStructureSkin(): ?bool {
if (Skin::validateIsStructureSkin($this->isStructureSkin)) {
if (!is_null($this->isStructureSkin)) {
return $this->isStructureSkin; /*bool*/
} else {
return null;
}
}
throw new Exception('never get to this Skin::isStructureSkin');
}
/**
* @param bool|null
* @return bool
* @throws Exception
*/
public static function validateIsStructureSkin(?bool $value): bool {
if (!is_null($value)) {
if (!is_bool($value)) {
throw new Exception("Attribute Error:Skin::isStructureSkin");
}
}
return true;
}
/**
* @throws Exception
* @return ?bool
*/
public function getIsStructureSkin(): ?bool {
if (Skin::validateIsStructureSkin($this->isStructureSkin)) {
return $this->isStructureSkin;
}
throw new Exception('never get to getIsStructureSkin Skin::isStructureSkin');
}
/**
* @return ?bool
*/
public static function sampleIsStructureSkin(): ?bool {
return true; /*34:isStructureSkin*/
}
/**
* @param ?stdClass $value
* @throws Exception
* @return ?SkinDescription
*/
public static function fromSkinDescription(?stdClass $value): ?SkinDescription {
if (!is_null($value)) {
return SkinDescription::from($value); /*class*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?stdClass
*/
public function toSkinDescription(): ?stdClass {
if (Skin::validateSkinDescription($this->skinDescription)) {
if (!is_null($this->skinDescription)) {
return $this->skinDescription->to(); /*class*/
} else {
return null;
}
}
throw new Exception('never get to this Skin::skinDescription');
}
/**
* @param SkinDescription|null
* @return bool
* @throws Exception
*/
public static function validateSkinDescription(?SkinDescription $value): bool {
if (!is_null($value)) {
$value->validate();
}
return true;
}
/**
* @throws Exception
* @return ?SkinDescription
*/
public function getSkinDescription(): ?SkinDescription {
if (Skin::validateSkinDescription($this->skinDescription)) {
return $this->skinDescription;
}
throw new Exception('never get to getSkinDescription Skin::skinDescription');
}
/**
* @return ?SkinDescription
*/
public static function sampleSkinDescription(): ?SkinDescription {
return SkinDescription::sample(); /*35:skinDescription*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromSkinId(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toSkinId(): int {
if (Skin::validateSkinId($this->skinId)) {
return $this->skinId; /*int*/
}
throw new Exception('never get to this Skin::skinId');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateSkinId(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Skin::skinId");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getSkinId(): int {
if (Skin::validateSkinId($this->skinId)) {
return $this->skinId;
}
throw new Exception('never get to getSkinId Skin::skinId');
}
/**
* @return int
*/
public static function sampleSkinId(): int {
return 36; /*36:skinId*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromSkinMaterialId(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toSkinMaterialId(): int {
if (Skin::validateSkinMaterialId($this->skinMaterialId)) {
return $this->skinMaterialId; /*int*/
}
throw new Exception('never get to this Skin::skinMaterialId');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateSkinMaterialId(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Skin::skinMaterialId");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getSkinMaterialId(): int {
if (Skin::validateSkinMaterialId($this->skinMaterialId)) {
return $this->skinMaterialId;
}
throw new Exception('never get to getSkinMaterialId Skin::skinMaterialId');
}
/**
* @return int
*/
public static function sampleSkinMaterialId(): int {
return 37; /*37:skinMaterialId*/
}
/**
* @param array $value
* @throws Exception
* @return array
*/
public static function fromTypes(array $value): array {
return array_map(function ($value) {
return $value; /*int*/
}, $value);
}
/**
* @throws Exception
* @return array
*/
public function toTypes(): array {
if (Skin::validateTypes($this->types)) {
return array_map(function ($value) {
return $value; /*int*/
}, $this->types);
}
throw new Exception('never get to this Skin::types');
}
/**
* @param array
* @return bool
* @throws Exception
*/
public static function validateTypes(array $value): bool {
if (!is_array($value)) {
throw new Exception("Attribute Error:Skin::types");
}
array_walk($value, function($value_v) {
if (!is_integer($value_v)) {
throw new Exception("Attribute Error:Skin::types");
}
});
return true;
}
/**
* @throws Exception
* @return array
*/
public function getTypes(): array {
if (Skin::validateTypes($this->types)) {
return $this->types;
}
throw new Exception('never get to getTypes Skin::types');
}
/**
* @return array
*/
public static function sampleTypes(): array {
return array(
38 /*38:*/
); /* 38:types*/
}
/**
* @param bool $value
* @throws Exception
* @return bool
*/
public static function fromVisibleSerenity(bool $value): bool {
return $value; /*bool*/
}
/**
* @throws Exception
* @return bool
*/
public function toVisibleSerenity(): bool {
if (Skin::validateVisibleSerenity($this->visibleSerenity)) {
return $this->visibleSerenity; /*bool*/
}
throw new Exception('never get to this Skin::visibleSerenity');
}
/**
* @param bool
* @return bool
* @throws Exception
*/
public static function validateVisibleSerenity(bool $value): bool {
if (!is_bool($value)) {
throw new Exception("Attribute Error:Skin::visibleSerenity");
}
return true;
}
/**
* @throws Exception
* @return bool
*/
public function getVisibleSerenity(): bool {
if (Skin::validateVisibleSerenity($this->visibleSerenity)) {
return $this->visibleSerenity;
}
throw new Exception('never get to getVisibleSerenity Skin::visibleSerenity');
}
/**
* @return bool
*/
public static function sampleVisibleSerenity(): bool {
return true; /*39:visibleSerenity*/
}
/**
* @param bool $value
* @throws Exception
* @return bool
*/
public static function fromVisibleTranquility(bool $value): bool {
return $value; /*bool*/
}
/**
* @throws Exception
* @return bool
*/
public function toVisibleTranquility(): bool {
if (Skin::validateVisibleTranquility($this->visibleTranquility)) {
return $this->visibleTranquility; /*bool*/
}
throw new Exception('never get to this Skin::visibleTranquility');
}
/**
* @param bool
* @return bool
* @throws Exception
*/
public static function validateVisibleTranquility(bool $value): bool {
if (!is_bool($value)) {
throw new Exception("Attribute Error:Skin::visibleTranquility");
}
return true;
}
/**
* @throws Exception
* @return bool
*/
public function getVisibleTranquility(): bool {
if (Skin::validateVisibleTranquility($this->visibleTranquility)) {
return $this->visibleTranquility;
}
throw new Exception('never get to getVisibleTranquility Skin::visibleTranquility');
}
/**
* @return bool
*/
public static function sampleVisibleTranquility(): bool {
return true; /*40:visibleTranquility*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return Skin::validateKey($this->key)
|| Skin::validateAllowCcpDevs($this->allowCcpDevs)
|| Skin::validateInternalName($this->internalName)
|| Skin::validateIsStructureSkin($this->isStructureSkin)
|| Skin::validateSkinDescription($this->skinDescription)
|| Skin::validateSkinId($this->skinId)
|| Skin::validateSkinMaterialId($this->skinMaterialId)
|| Skin::validateTypes($this->types)
|| Skin::validateVisibleSerenity($this->visibleSerenity)
|| Skin::validateVisibleTranquility($this->visibleTranquility);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'allowCCPDevs'} = $this->toAllowCcpDevs();
$out->{'internalName'} = $this->toInternalName();
$out->{'isStructureSkin'} = $this->toIsStructureSkin();
$out->{'skinDescription'} = $this->toSkinDescription();
$out->{'skinID'} = $this->toSkinId();
$out->{'skinMaterialID'} = $this->toSkinMaterialId();
$out->{'types'} = $this->toTypes();
$out->{'visibleSerenity'} = $this->toVisibleSerenity();
$out->{'visibleTranquility'} = $this->toVisibleTranquility();
return $out;
}
/**
* @param stdClass $obj
* @return Skin
* @throws Exception
*/
public static function from(stdClass $obj): Skin {
return new Skin(
Skin::fromKey($obj->{'_key'})
,Skin::fromAllowCcpDevs($obj->{'allowCCPDevs'})
,Skin::fromInternalName($obj->{'internalName'})
,Skin::fromIsStructureSkin($obj->{'isStructureSkin'})
,Skin::fromSkinDescription($obj->{'skinDescription'})
,Skin::fromSkinId($obj->{'skinID'})
,Skin::fromSkinMaterialId($obj->{'skinMaterialID'})
,Skin::fromTypes($obj->{'types'})
,Skin::fromVisibleSerenity($obj->{'visibleSerenity'})
,Skin::fromVisibleTranquility($obj->{'visibleTranquility'})
);
}
/**
* @return Skin
*/
public static function sample(): Skin {
return new Skin(
Skin::sampleKey()
,Skin::sampleAllowCcpDevs()
,Skin::sampleInternalName()
,Skin::sampleIsStructureSkin()
,Skin::sampleSkinDescription()
,Skin::sampleSkinId()
,Skin::sampleSkinMaterialId()
,Skin::sampleTypes()
,Skin::sampleVisibleSerenity()
,Skin::sampleVisibleTranquility()
);
}
}
// This is a autogenerated file:SkinDescription
class SkinDescription {
private ?string $de; // json:de Optional
private string $en; // json:en Required
private ?string $es; // json:es Optional
private ?string $fr; // json:fr Optional
private ?string $ja; // json:ja Optional
private ?string $ko; // json:ko Optional
private ?string $ru; // json:ru Optional
private ?string $zh; // json:zh Optional
/**
* @param string|null $de
* @param string $en
* @param string|null $es
* @param string|null $fr
* @param string|null $ja
* @param string|null $ko
* @param string|null $ru
* @param string|null $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 {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toDe(): ?string {
if (SkinDescription::validateDe($this->de)) {
if (!is_null($this->de)) {
return $this->de; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this SkinDescription::de');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateDe(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:SkinDescription::de");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getDe(): ?string {
if (SkinDescription::validateDe($this->de)) {
return $this->de;
}
throw new Exception('never get to getDe SkinDescription::de');
}
/**
* @return ?string
*/
public static function sampleDe(): ?string {
return 'SkinDescription::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 (SkinDescription::validateEn($this->en)) {
return $this->en; /*string*/
}
throw new Exception('never get to this SkinDescription::en');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateEn(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:SkinDescription::en");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getEn(): string {
if (SkinDescription::validateEn($this->en)) {
return $this->en;
}
throw new Exception('never get to getEn SkinDescription::en');
}
/**
* @return string
*/
public static function sampleEn(): string {
return 'SkinDescription::en::32'; /*32:en*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromEs(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toEs(): ?string {
if (SkinDescription::validateEs($this->es)) {
if (!is_null($this->es)) {
return $this->es; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this SkinDescription::es');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateEs(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:SkinDescription::es");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getEs(): ?string {
if (SkinDescription::validateEs($this->es)) {
return $this->es;
}
throw new Exception('never get to getEs SkinDescription::es');
}
/**
* @return ?string
*/
public static function sampleEs(): ?string {
return 'SkinDescription::es::33'; /*33:es*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromFr(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toFr(): ?string {
if (SkinDescription::validateFr($this->fr)) {
if (!is_null($this->fr)) {
return $this->fr; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this SkinDescription::fr');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateFr(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:SkinDescription::fr");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getFr(): ?string {
if (SkinDescription::validateFr($this->fr)) {
return $this->fr;
}
throw new Exception('never get to getFr SkinDescription::fr');
}
/**
* @return ?string
*/
public static function sampleFr(): ?string {
return 'SkinDescription::fr::34'; /*34:fr*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromJa(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toJa(): ?string {
if (SkinDescription::validateJa($this->ja)) {
if (!is_null($this->ja)) {
return $this->ja; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this SkinDescription::ja');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateJa(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:SkinDescription::ja");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getJa(): ?string {
if (SkinDescription::validateJa($this->ja)) {
return $this->ja;
}
throw new Exception('never get to getJa SkinDescription::ja');
}
/**
* @return ?string
*/
public static function sampleJa(): ?string {
return 'SkinDescription::ja::35'; /*35:ja*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromKo(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toKo(): ?string {
if (SkinDescription::validateKo($this->ko)) {
if (!is_null($this->ko)) {
return $this->ko; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this SkinDescription::ko');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateKo(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:SkinDescription::ko");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getKo(): ?string {
if (SkinDescription::validateKo($this->ko)) {
return $this->ko;
}
throw new Exception('never get to getKo SkinDescription::ko');
}
/**
* @return ?string
*/
public static function sampleKo(): ?string {
return 'SkinDescription::ko::36'; /*36:ko*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromRu(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toRu(): ?string {
if (SkinDescription::validateRu($this->ru)) {
if (!is_null($this->ru)) {
return $this->ru; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this SkinDescription::ru');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateRu(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:SkinDescription::ru");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getRu(): ?string {
if (SkinDescription::validateRu($this->ru)) {
return $this->ru;
}
throw new Exception('never get to getRu SkinDescription::ru');
}
/**
* @return ?string
*/
public static function sampleRu(): ?string {
return 'SkinDescription::ru::37'; /*37:ru*/
}
/**
* @param ?string $value
* @throws Exception
* @return ?string
*/
public static function fromZh(?string $value): ?string {
if (!is_null($value)) {
return $value; /*string*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?string
*/
public function toZh(): ?string {
if (SkinDescription::validateZh($this->zh)) {
if (!is_null($this->zh)) {
return $this->zh; /*string*/
} else {
return null;
}
}
throw new Exception('never get to this SkinDescription::zh');
}
/**
* @param string|null
* @return bool
* @throws Exception
*/
public static function validateZh(?string $value): bool {
if (!is_null($value)) {
if (!is_string($value)) {
throw new Exception("Attribute Error:SkinDescription::zh");
}
}
return true;
}
/**
* @throws Exception
* @return ?string
*/
public function getZh(): ?string {
if (SkinDescription::validateZh($this->zh)) {
return $this->zh;
}
throw new Exception('never get to getZh SkinDescription::zh');
}
/**
* @return ?string
*/
public static function sampleZh(): ?string {
return 'SkinDescription::zh::38'; /*38:zh*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return SkinDescription::validateDe($this->de)
|| SkinDescription::validateEn($this->en)
|| SkinDescription::validateEs($this->es)
|| SkinDescription::validateFr($this->fr)
|| SkinDescription::validateJa($this->ja)
|| SkinDescription::validateKo($this->ko)
|| SkinDescription::validateRu($this->ru)
|| SkinDescription::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 SkinDescription
* @throws Exception
*/
public static function from(stdClass $obj): SkinDescription {
return new SkinDescription(
SkinDescription::fromDe($obj->{'de'})
,SkinDescription::fromEn($obj->{'en'})
,SkinDescription::fromEs($obj->{'es'})
,SkinDescription::fromFr($obj->{'fr'})
,SkinDescription::fromJa($obj->{'ja'})
,SkinDescription::fromKo($obj->{'ko'})
,SkinDescription::fromRu($obj->{'ru'})
,SkinDescription::fromZh($obj->{'zh'})
);
}
/**
* @return SkinDescription
*/
public static function sample(): SkinDescription {
return new SkinDescription(
SkinDescription::sampleDe()
,SkinDescription::sampleEn()
,SkinDescription::sampleEs()
,SkinDescription::sampleFr()
,SkinDescription::sampleJa()
,SkinDescription::sampleKo()
,SkinDescription::sampleRu()
,SkinDescription::sampleZh()
);
}
}
from typing import Optional, Any, List, TypeVar, Callable, Type, cast
T = TypeVar("T")
def from_str(x: Any) -> str:
assert isinstance(x, str)
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_int(x: Any) -> int:
assert isinstance(x, int) and not isinstance(x, bool)
return x
def from_bool(x: Any) -> bool:
assert isinstance(x, bool)
return x
def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
assert isinstance(x, list)
return [f(y) for y in x]
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
class SkinDescription:
de: Optional[str]
en: str
es: Optional[str]
fr: Optional[str]
ja: Optional[str]
ko: Optional[str]
ru: Optional[str]
zh: Optional[str]
def __init__(self, de: Optional[str], en: str, es: Optional[str], fr: Optional[str], ja: Optional[str], ko: Optional[str], ru: Optional[str], zh: Optional[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) -> 'SkinDescription':
assert isinstance(obj, dict)
de = from_union([from_str, from_none], obj.get("de"))
en = from_str(obj.get("en"))
es = from_union([from_str, from_none], obj.get("es"))
fr = from_union([from_str, from_none], obj.get("fr"))
ja = from_union([from_str, from_none], obj.get("ja"))
ko = from_union([from_str, from_none], obj.get("ko"))
ru = from_union([from_str, from_none], obj.get("ru"))
zh = from_union([from_str, from_none], obj.get("zh"))
return SkinDescription(de, en, es, fr, ja, ko, ru, zh)
def to_dict(self) -> dict:
result: dict = {}
if self.de is not None:
result["de"] = from_union([from_str, from_none], self.de)
result["en"] = from_str(self.en)
if self.es is not None:
result["es"] = from_union([from_str, from_none], self.es)
if self.fr is not None:
result["fr"] = from_union([from_str, from_none], self.fr)
if self.ja is not None:
result["ja"] = from_union([from_str, from_none], self.ja)
if self.ko is not None:
result["ko"] = from_union([from_str, from_none], self.ko)
if self.ru is not None:
result["ru"] = from_union([from_str, from_none], self.ru)
if self.zh is not None:
result["zh"] = from_union([from_str, from_none], self.zh)
return result
class Skin:
key: int
allow_ccp_devs: bool
internal_name: str
is_structure_skin: Optional[bool]
skin_description: Optional[SkinDescription]
skin_id: int
skin_material_id: int
types: List[int]
visible_serenity: bool
visible_tranquility: bool
def __init__(self, key: int, allow_ccp_devs: bool, internal_name: str, is_structure_skin: Optional[bool], skin_description: Optional[SkinDescription], skin_id: int, skin_material_id: int, types: List[int], visible_serenity: bool, visible_tranquility: bool) -> None:
self.key = key
self.allow_ccp_devs = allow_ccp_devs
self.internal_name = internal_name
self.is_structure_skin = is_structure_skin
self.skin_description = skin_description
self.skin_id = skin_id
self.skin_material_id = skin_material_id
self.types = types
self.visible_serenity = visible_serenity
self.visible_tranquility = visible_tranquility
@staticmethod
def from_dict(obj: Any) -> 'Skin':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
allow_ccp_devs = from_bool(obj.get("allowCCPDevs"))
internal_name = from_str(obj.get("internalName"))
is_structure_skin = from_union([from_bool, from_none], obj.get("isStructureSkin"))
skin_description = from_union([SkinDescription.from_dict, from_none], obj.get("skinDescription"))
skin_id = from_int(obj.get("skinID"))
skin_material_id = from_int(obj.get("skinMaterialID"))
types = from_list(from_int, obj.get("types"))
visible_serenity = from_bool(obj.get("visibleSerenity"))
visible_tranquility = from_bool(obj.get("visibleTranquility"))
return Skin(key, allow_ccp_devs, internal_name, is_structure_skin, skin_description, skin_id, skin_material_id, types, visible_serenity, visible_tranquility)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["allowCCPDevs"] = from_bool(self.allow_ccp_devs)
result["internalName"] = from_str(self.internal_name)
if self.is_structure_skin is not None:
result["isStructureSkin"] = from_union([from_bool, from_none], self.is_structure_skin)
if self.skin_description is not None:
result["skinDescription"] = from_union([lambda x: to_class(SkinDescription, x), from_none], self.skin_description)
result["skinID"] = from_int(self.skin_id)
result["skinMaterialID"] = from_int(self.skin_material_id)
result["types"] = from_list(from_int, self.types)
result["visibleSerenity"] = from_bool(self.visible_serenity)
result["visibleTranquility"] = from_bool(self.visible_tranquility)
return result
def skin_from_dict(s: Any) -> Skin:
return Skin.from_dict(s)
def skin_to_dict(x: Skin) -> Any:
return to_class(Skin, x)
// To parse this data:
//
// import { Convert, Skin } from "./file";
//
// const skin = Convert.toSkin(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface Skin {
_key: number;
allowCCPDevs: boolean;
internalName: string;
isStructureSkin?: boolean;
skinDescription?: SkinDescription;
skinID: number;
skinMaterialID: number;
types: number[];
visibleSerenity: boolean;
visibleTranquility: boolean;
[property: string]: any;
}
export interface SkinDescription {
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 toSkin(json: string): Skin {
return cast(JSON.parse(json), r("Skin"));
}
public static skinToJson(value: Skin): string {
return JSON.stringify(uncast(value, r("Skin")), 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 = {
"Skin": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "allowCCPDevs", js: "allowCCPDevs", typ: true },
{ json: "internalName", js: "internalName", typ: "" },
{ json: "isStructureSkin", js: "isStructureSkin", typ: u(undefined, true) },
{ json: "skinDescription", js: "skinDescription", typ: u(undefined, r("SkinDescription")) },
{ json: "skinID", js: "skinID", typ: 0 },
{ json: "skinMaterialID", js: "skinMaterialID", typ: 0 },
{ json: "types", js: "types", typ: a(0) },
{ json: "visibleSerenity", js: "visibleSerenity", typ: true },
{ json: "visibleTranquility", js: "visibleTranquility", typ: true },
], "any"),
"SkinDescription": o([
{ json: "de", js: "de", typ: u(undefined, "") },
{ json: "en", js: "en", typ: "" },
{ json: "es", js: "es", typ: u(undefined, "") },
{ json: "fr", js: "fr", typ: u(undefined, "") },
{ json: "ja", js: "ja", typ: u(undefined, "") },
{ json: "ko", js: "ko", typ: u(undefined, "") },
{ json: "ru", js: "ru", typ: u(undefined, "") },
{ json: "zh", js: "zh", typ: u(undefined, "") },
], "any"),
};