skinrSlotConfigurations.jsonl
Schema
_key(required): integer
Range: 5 .. 8allowAllShips: booleanconfig: array of integer
Type:integer
Range: 1 .. 8name(required): stringpriority(required): integer
Range: 0 .. 3ships: array of integer
Type:integer
Range: 615 .. 89808
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var skinrSlotConfiguration = SkinrSlotConfiguration.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class SkinrSlotConfiguration
{
[JsonProperty("_key")]
public long Key { get; set; }
[JsonProperty("allowAllShips", NullValueHandling = NullValueHandling.Ignore)]
public bool? AllowAllShips { get; set; }
[JsonProperty("config", NullValueHandling = NullValueHandling.Ignore)]
public long[] Config { get; set; }
[JsonProperty("name")]
[JsonConverter(typeof(MinMaxLengthCheckConverter))]
public string Name { get; set; }
[JsonProperty("priority")]
public long Priority { get; set; }
[JsonProperty("ships", NullValueHandling = NullValueHandling.Ignore)]
public long[] Ships { get; set; }
}
public partial class SkinrSlotConfiguration
{
public static SkinrSlotConfiguration FromJson(string json) => JsonConvert.DeserializeObject<SkinrSlotConfiguration>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this SkinrSlotConfiguration 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 MinMaxLengthCheckConverter : 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 >= 15 && value.Length <= 23)
{
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 >= 15 && value.Length <= 23)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type string");
}
public static readonly MinMaxLengthCheckConverter Singleton = new MinMaxLengthCheckConverter();
}
}
// 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:
//
// skinrSlotConfiguration, err := UnmarshalSkinrSlotConfiguration(bytes)
// bytes, err = skinrSlotConfiguration.Marshal()
package model
import "encoding/json"
func UnmarshalSkinrSlotConfiguration(data []byte) (SkinrSlotConfiguration, error) {
var r SkinrSlotConfiguration
err := json.Unmarshal(data, &r)
return r, err
}
func (r *SkinrSlotConfiguration) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type SkinrSlotConfiguration struct {
Key int64 `json:"_key"`
AllowAllShips *bool `json:"allowAllShips,omitempty"`
Config []int64 `json:"config,omitempty"`
Name string `json:"name"`
Priority int64 `json:"priority"`
Ships []int64 `json:"ships,omitempty"`
}
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"_key":{"type":"integer","minimum":5,"maximum":8},"allowAllShips":{"type":"boolean"},"config":{"type":"array","items":{"type":"integer","minimum":1,"maximum":8},"minItems":7,"maxItems":8},"name":{"type":"string","minLength":15,"maxLength":23},"priority":{"type":"integer","minimum":0,"maximum":3},"ships":{"type":"array","items":{"type":"integer","minimum":615,"maximum":89808},"minItems":3,"maxItems":85}},"required":["_key","name","priority"]}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val skinrSlotConfiguration = json.parse(SkinrSlotConfiguration.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class SkinrSlotConfiguration (
@SerialName("_key")
val key: Long,
val allowAllShips: Boolean? = null,
val config: List<Long>? = null,
val name: String,
val priority: Long,
val ships: List<Long>? = null
)
<?php
// This is a autogenerated file:SkinrSlotConfiguration
class SkinrSlotConfiguration {
private int $key; // json:_key Required
private ?bool $allowAllShips; // json:allowAllShips Optional
private ?array $config; // json:config Optional
private string $name; // json:name Required
private int $priority; // json:priority Required
private ?array $ships; // json:ships Optional
/**
* @param int $key
* @param bool|null $allowAllShips
* @param array|null $config
* @param string $name
* @param int $priority
* @param array|null $ships
*/
public function __construct(int $key, ?bool $allowAllShips, ?array $config, string $name, int $priority, ?array $ships) {
$this->key = $key;
$this->allowAllShips = $allowAllShips;
$this->config = $config;
$this->name = $name;
$this->priority = $priority;
$this->ships = $ships;
}
/**
* @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 (SkinrSlotConfiguration::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this SkinrSlotConfiguration::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:SkinrSlotConfiguration::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (SkinrSlotConfiguration::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey SkinrSlotConfiguration::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param ?bool $value
* @throws Exception
* @return ?bool
*/
public static function fromAllowAllShips(?bool $value): ?bool {
if (!is_null($value)) {
return $value; /*bool*/
} else {
return null;
}
}
/**
* @throws Exception
* @return ?bool
*/
public function toAllowAllShips(): ?bool {
if (SkinrSlotConfiguration::validateAllowAllShips($this->allowAllShips)) {
if (!is_null($this->allowAllShips)) {
return $this->allowAllShips; /*bool*/
} else {
return null;
}
}
throw new Exception('never get to this SkinrSlotConfiguration::allowAllShips');
}
/**
* @param bool|null
* @return bool
* @throws Exception
*/
public static function validateAllowAllShips(?bool $value): bool {
if (!is_null($value)) {
if (!is_bool($value)) {
throw new Exception("Attribute Error:SkinrSlotConfiguration::allowAllShips");
}
}
return true;
}
/**
* @throws Exception
* @return ?bool
*/
public function getAllowAllShips(): ?bool {
if (SkinrSlotConfiguration::validateAllowAllShips($this->allowAllShips)) {
return $this->allowAllShips;
}
throw new Exception('never get to getAllowAllShips SkinrSlotConfiguration::allowAllShips');
}
/**
* @return ?bool
*/
public static function sampleAllowAllShips(): ?bool {
return true; /*32:allowAllShips*/
}
/**
* @param ?array $value
* @throws Exception
* @return ?array
*/
public static function fromConfig(?array $value): ?array {
if (!is_null($value)) {
return array_map(function ($value) {
return $value; /*int*/
}, $value);
} else {
return null;
}
}
/**
* @throws Exception
* @return ?array
*/
public function toConfig(): ?array {
if (SkinrSlotConfiguration::validateConfig($this->config)) {
if (!is_null($this->config)) {
return array_map(function ($value) {
return $value; /*int*/
}, $this->config);
} else {
return null;
}
}
throw new Exception('never get to this SkinrSlotConfiguration::config');
}
/**
* @param array|null
* @return bool
* @throws Exception
*/
public static function validateConfig(?array $value): bool {
if (!is_null($value)) {
if (!is_array($value)) {
throw new Exception("Attribute Error:SkinrSlotConfiguration::config");
}
array_walk($value, function($value_v) {
if (!is_integer($value_v)) {
throw new Exception("Attribute Error:SkinrSlotConfiguration::config");
}
});
}
return true;
}
/**
* @throws Exception
* @return ?array
*/
public function getConfig(): ?array {
if (SkinrSlotConfiguration::validateConfig($this->config)) {
return $this->config;
}
throw new Exception('never get to getConfig SkinrSlotConfiguration::config');
}
/**
* @return ?array
*/
public static function sampleConfig(): ?array {
return array(
33 /*33:*/
); /* 33:config*/
}
/**
* @param string $value
* @throws Exception
* @return string
*/
public static function fromName(string $value): string {
return $value; /*string*/
}
/**
* @throws Exception
* @return string
*/
public function toName(): string {
if (SkinrSlotConfiguration::validateName($this->name)) {
return $this->name; /*string*/
}
throw new Exception('never get to this SkinrSlotConfiguration::name');
}
/**
* @param string
* @return bool
* @throws Exception
*/
public static function validateName(string $value): bool {
if (!is_string($value)) {
throw new Exception("Attribute Error:SkinrSlotConfiguration::name");
}
return true;
}
/**
* @throws Exception
* @return string
*/
public function getName(): string {
if (SkinrSlotConfiguration::validateName($this->name)) {
return $this->name;
}
throw new Exception('never get to getName SkinrSlotConfiguration::name');
}
/**
* @return string
*/
public static function sampleName(): string {
return 'SkinrSlotConfiguration::name::34'; /*34:name*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromPriority(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toPriority(): int {
if (SkinrSlotConfiguration::validatePriority($this->priority)) {
return $this->priority; /*int*/
}
throw new Exception('never get to this SkinrSlotConfiguration::priority');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validatePriority(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:SkinrSlotConfiguration::priority");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getPriority(): int {
if (SkinrSlotConfiguration::validatePriority($this->priority)) {
return $this->priority;
}
throw new Exception('never get to getPriority SkinrSlotConfiguration::priority');
}
/**
* @return int
*/
public static function samplePriority(): int {
return 35; /*35:priority*/
}
/**
* @param ?array $value
* @throws Exception
* @return ?array
*/
public static function fromShips(?array $value): ?array {
if (!is_null($value)) {
return array_map(function ($value) {
return $value; /*int*/
}, $value);
} else {
return null;
}
}
/**
* @throws Exception
* @return ?array
*/
public function toShips(): ?array {
if (SkinrSlotConfiguration::validateShips($this->ships)) {
if (!is_null($this->ships)) {
return array_map(function ($value) {
return $value; /*int*/
}, $this->ships);
} else {
return null;
}
}
throw new Exception('never get to this SkinrSlotConfiguration::ships');
}
/**
* @param array|null
* @return bool
* @throws Exception
*/
public static function validateShips(?array $value): bool {
if (!is_null($value)) {
if (!is_array($value)) {
throw new Exception("Attribute Error:SkinrSlotConfiguration::ships");
}
array_walk($value, function($value_v) {
if (!is_integer($value_v)) {
throw new Exception("Attribute Error:SkinrSlotConfiguration::ships");
}
});
}
return true;
}
/**
* @throws Exception
* @return ?array
*/
public function getShips(): ?array {
if (SkinrSlotConfiguration::validateShips($this->ships)) {
return $this->ships;
}
throw new Exception('never get to getShips SkinrSlotConfiguration::ships');
}
/**
* @return ?array
*/
public static function sampleShips(): ?array {
return array(
36 /*36:*/
); /* 36:ships*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return SkinrSlotConfiguration::validateKey($this->key)
|| SkinrSlotConfiguration::validateAllowAllShips($this->allowAllShips)
|| SkinrSlotConfiguration::validateConfig($this->config)
|| SkinrSlotConfiguration::validateName($this->name)
|| SkinrSlotConfiguration::validatePriority($this->priority)
|| SkinrSlotConfiguration::validateShips($this->ships);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'allowAllShips'} = $this->toAllowAllShips();
$out->{'config'} = $this->toConfig();
$out->{'name'} = $this->toName();
$out->{'priority'} = $this->toPriority();
$out->{'ships'} = $this->toShips();
return $out;
}
/**
* @param stdClass $obj
* @return SkinrSlotConfiguration
* @throws Exception
*/
public static function from(stdClass $obj): SkinrSlotConfiguration {
return new SkinrSlotConfiguration(
SkinrSlotConfiguration::fromKey($obj->{'_key'})
,SkinrSlotConfiguration::fromAllowAllShips($obj->{'allowAllShips'})
,SkinrSlotConfiguration::fromConfig($obj->{'config'})
,SkinrSlotConfiguration::fromName($obj->{'name'})
,SkinrSlotConfiguration::fromPriority($obj->{'priority'})
,SkinrSlotConfiguration::fromShips($obj->{'ships'})
);
}
/**
* @return SkinrSlotConfiguration
*/
public static function sample(): SkinrSlotConfiguration {
return new SkinrSlotConfiguration(
SkinrSlotConfiguration::sampleKey()
,SkinrSlotConfiguration::sampleAllowAllShips()
,SkinrSlotConfiguration::sampleConfig()
,SkinrSlotConfiguration::sampleName()
,SkinrSlotConfiguration::samplePriority()
,SkinrSlotConfiguration::sampleShips()
);
}
}
from typing import Optional, List, Any, TypeVar, Callable, Type, cast
T = TypeVar("T")
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_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_str(x: Any) -> str:
assert isinstance(x, str)
return x
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
class SkinrSlotConfiguration:
key: int
allow_all_ships: Optional[bool]
config: Optional[List[int]]
name: str
priority: int
ships: Optional[List[int]]
def __init__(self, key: int, allow_all_ships: Optional[bool], config: Optional[List[int]], name: str, priority: int, ships: Optional[List[int]]) -> None:
self.key = key
self.allow_all_ships = allow_all_ships
self.config = config
self.name = name
self.priority = priority
self.ships = ships
@staticmethod
def from_dict(obj: Any) -> 'SkinrSlotConfiguration':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
allow_all_ships = from_union([from_bool, from_none], obj.get("allowAllShips"))
config = from_union([lambda x: from_list(from_int, x), from_none], obj.get("config"))
name = from_str(obj.get("name"))
priority = from_int(obj.get("priority"))
ships = from_union([lambda x: from_list(from_int, x), from_none], obj.get("ships"))
return SkinrSlotConfiguration(key, allow_all_ships, config, name, priority, ships)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
if self.allow_all_ships is not None:
result["allowAllShips"] = from_union([from_bool, from_none], self.allow_all_ships)
if self.config is not None:
result["config"] = from_union([lambda x: from_list(from_int, x), from_none], self.config)
result["name"] = from_str(self.name)
result["priority"] = from_int(self.priority)
if self.ships is not None:
result["ships"] = from_union([lambda x: from_list(from_int, x), from_none], self.ships)
return result
def skinr_slot_configuration_from_dict(s: Any) -> SkinrSlotConfiguration:
return SkinrSlotConfiguration.from_dict(s)
def skinr_slot_configuration_to_dict(x: SkinrSlotConfiguration) -> Any:
return to_class(SkinrSlotConfiguration, x)
// To parse this data:
//
// import { Convert, SkinrSlotConfiguration } from "./file";
//
// const skinrSlotConfiguration = Convert.toSkinrSlotConfiguration(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface SkinrSlotConfiguration {
_key: number;
allowAllShips?: boolean;
config?: number[];
name: string;
priority: number;
ships?: number[];
[property: string]: any;
}
// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
public static toSkinrSlotConfiguration(json: string): SkinrSlotConfiguration {
return cast(JSON.parse(json), r("SkinrSlotConfiguration"));
}
public static skinrSlotConfigurationToJson(value: SkinrSlotConfiguration): string {
return JSON.stringify(uncast(value, r("SkinrSlotConfiguration")), 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 = {
"SkinrSlotConfiguration": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "allowAllShips", js: "allowAllShips", typ: u(undefined, true) },
{ json: "config", js: "config", typ: u(undefined, a(0)) },
{ json: "name", js: "name", typ: "" },
{ json: "priority", js: "priority", typ: 0 },
{ json: "ships", js: "ships", typ: u(undefined, a(0)) },
], "any"),
};