systemDbuffEmitters.jsonl
Schema
_key(required): integer
Range: 79839 .. 79839-
dbuffs(required): array of object_key(required): integer
Range: 2405 .. 2405_value(required): number
Range: 10 .. 10
-
duration(required): integer
Range: 300 .. 300 excludeProtected(required): booleaninterval(required): integer
Range: 30 .. 30
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
// using QuickType;
//
// var systemDbuffEmitter = SystemDbuffEmitter.FromJson(jsonString);
#nullable enable
#pragma warning disable CS8618
#pragma warning disable CS8601
#pragma warning disable CS8602
#pragma warning disable CS8603
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Globalization;
public partial class SystemDbuffEmitter
{
[JsonPropertyName("_key")]
public long Key { get; set; }
[JsonPropertyName("dbuffs")]
public Dbuff[] Dbuffs { get; set; }
[JsonPropertyName("duration")]
public long Duration { get; set; }
[JsonPropertyName("excludeProtected")]
public bool ExcludeProtected { get; set; }
[JsonPropertyName("interval")]
public long Interval { get; set; }
}
public partial class Dbuff
{
[JsonPropertyName("_key")]
public long Key { get; set; }
[JsonPropertyName("_value")]
[JsonConverter(typeof(MinMaxValueCheckConverter))]
public double Value { get; set; }
}
public partial class SystemDbuffEmitter
{
public static SystemDbuffEmitter FromJson(string json) => JsonSerializer.Deserialize<SystemDbuffEmitter>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this SystemDbuffEmitter self) => JsonSerializer.Serialize(self, QuickType.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerOptions Settings = new(JsonSerializerDefaults.General)
{
Converters =
{
new DateOnlyConverter(),
new TimeOnlyConverter(),
IsoDateTimeOffsetConverter.Singleton
},
};
}
internal class MinMaxValueCheckConverter : JsonConverter<double>
{
public override bool CanConvert(Type t) => t == typeof(double);
public override double Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetDouble();
if (value >= 10 && value <= 10)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options)
{
if (value >= 10 && value <= 10)
{
JsonSerializer.Serialize(writer, value, options);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly MinMaxValueCheckConverter Singleton = new MinMaxValueCheckConverter();
}
public class DateOnlyConverter : JsonConverter<DateOnly>
{
private readonly string serializationFormat;
public DateOnlyConverter() : this(null) { }
public DateOnlyConverter(string? serializationFormat)
{
this.serializationFormat = serializationFormat ?? "yyyy-MM-dd";
}
public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
return DateOnly.Parse(value!);
}
public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToString(serializationFormat));
}
public class TimeOnlyConverter : JsonConverter<TimeOnly>
{
private readonly string serializationFormat;
public TimeOnlyConverter() : this(null) { }
public TimeOnlyConverter(string? serializationFormat)
{
this.serializationFormat = serializationFormat ?? "HH:mm:ss.fff";
}
public override TimeOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var value = reader.GetString();
return TimeOnly.Parse(value!);
}
public override void Write(Utf8JsonWriter writer, TimeOnly value, JsonSerializerOptions options)
=> writer.WriteStringValue(value.ToString(serializationFormat));
}
internal class IsoDateTimeOffsetConverter : JsonConverter<DateTimeOffset>
{
public override bool CanConvert(Type t) => t == typeof(DateTimeOffset);
private const string DefaultDateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind;
private string? _dateTimeFormat;
private CultureInfo? _culture;
public DateTimeStyles DateTimeStyles
{
get => _dateTimeStyles;
set => _dateTimeStyles = value;
}
public string? DateTimeFormat
{
get => _dateTimeFormat ?? string.Empty;
set => _dateTimeFormat = (string.IsNullOrEmpty(value)) ? null : value;
}
public CultureInfo Culture
{
get => _culture ?? CultureInfo.CurrentCulture;
set => _culture = value;
}
public override void Write(Utf8JsonWriter writer, DateTimeOffset value, JsonSerializerOptions options)
{
string text;
if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal
|| (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal)
{
value = value.ToUniversalTime();
}
text = value.ToString(_dateTimeFormat ?? DefaultDateTimeFormat, Culture);
writer.WriteStringValue(text);
}
public override DateTimeOffset Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
string? dateText = reader.GetString();
if (string.IsNullOrEmpty(dateText) == false)
{
if (!string.IsNullOrEmpty(_dateTimeFormat))
{
return DateTimeOffset.ParseExact(dateText, _dateTimeFormat, Culture, _dateTimeStyles);
}
else
{
return DateTimeOffset.Parse(dateText, Culture, _dateTimeStyles);
}
}
else
{
return default(DateTimeOffset);
}
}
public static readonly IsoDateTimeOffsetConverter Singleton = new IsoDateTimeOffsetConverter();
}
}
#pragma warning restore CS8618
#pragma warning restore CS8601
#pragma warning restore CS8602
#pragma warning restore CS8603
// 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:
//
// systemDbuffEmitter, err := UnmarshalSystemDbuffEmitter(bytes)
// bytes, err = systemDbuffEmitter.Marshal()
package model
import "encoding/json"
func UnmarshalSystemDbuffEmitter(data []byte) (SystemDbuffEmitter, error) {
var r SystemDbuffEmitter
err := json.Unmarshal(data, &r)
return r, err
}
func (r *SystemDbuffEmitter) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type SystemDbuffEmitter struct {
Key int64 `json:"_key"`
Dbuffs []Dbuff `json:"dbuffs"`
Duration int64 `json:"duration"`
ExcludeProtected bool `json:"excludeProtected"`
Interval int64 `json:"interval"`
}
type Dbuff struct {
Key int64 `json:"_key"`
Value float64 `json:"_value"`
}
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"_key":{"type":"integer","minimum":79839,"maximum":79839},"dbuffs":{"type":"array","items":{"type":"object","properties":{"_key":{"type":"integer","minimum":2405,"maximum":2405},"_value":{"type":"number","minimum":10.0,"maximum":10.0}},"required":["_key","_value"]},"minItems":1,"maxItems":1},"duration":{"type":"integer","minimum":300,"maximum":300},"excludeProtected":{"type":"boolean"},"interval":{"type":"integer","minimum":30,"maximum":30}},"required":["_key","dbuffs","duration","excludeProtected","interval"]}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val systemDbuffEmitter = json.parse(SystemDbuffEmitter.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class SystemDbuffEmitter (
@SerialName("_key")
val key: Long,
val dbuffs: List<Dbuff>,
val duration: Long,
val excludeProtected: Boolean,
val interval: Long
)
@Serializable
data class Dbuff (
@SerialName("_key")
val key: Long,
@SerialName("_value")
val value: Double
)
<?php
// This is an autogenerated file:SystemDbuffEmitter
class SystemDbuffEmitter {
private int $key; // json:_key Required
private array $dbuffs; // json:dbuffs Required
private int $duration; // json:duration Required
private bool $excludeProtected; // json:excludeProtected Required
private int $interval; // json:interval Required
/**
* @param int $key
* @param array $dbuffs
* @param int $duration
* @param bool $excludeProtected
* @param int $interval
*/
public function __construct(int $key, array $dbuffs, int $duration, bool $excludeProtected, int $interval) {
$this->key = $key;
$this->dbuffs = $dbuffs;
$this->duration = $duration;
$this->excludeProtected = $excludeProtected;
$this->interval = $interval;
}
/**
* @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 (SystemDbuffEmitter::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this SystemDbuffEmitter::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:SystemDbuffEmitter::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (SystemDbuffEmitter::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey SystemDbuffEmitter::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param array $value
* @throws Exception
* @return array
*/
public static function fromDbuffs(array $value): array {
return array_map(function ($value) {
return Dbuff::from($value); /*class*/
}, $value);
}
/**
* @throws Exception
* @return array
*/
public function toDbuffs(): array {
if (SystemDbuffEmitter::validateDbuffs($this->dbuffs)) {
return array_map(function ($value) {
return $value->to(); /*class*/
}, $this->dbuffs);
}
throw new Exception('never get to this SystemDbuffEmitter::dbuffs');
}
/**
* @param array
* @return bool
* @throws Exception
*/
public static function validateDbuffs(array $value): bool {
if (!is_array($value)) {
throw new Exception("Attribute Error:SystemDbuffEmitter::dbuffs");
}
array_walk($value, function($value_v) {
$value_v->validate();
});
return true;
}
/**
* @throws Exception
* @return array
*/
public function getDbuffs(): array {
if (SystemDbuffEmitter::validateDbuffs($this->dbuffs)) {
return $this->dbuffs;
}
throw new Exception('never get to getDbuffs SystemDbuffEmitter::dbuffs');
}
/**
* @return array
*/
public static function sampleDbuffs(): array {
return array(
Dbuff::sample() /*32:*/
); /* 32:dbuffs*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromDuration(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toDuration(): int {
if (SystemDbuffEmitter::validateDuration($this->duration)) {
return $this->duration; /*int*/
}
throw new Exception('never get to this SystemDbuffEmitter::duration');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateDuration(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:SystemDbuffEmitter::duration");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getDuration(): int {
if (SystemDbuffEmitter::validateDuration($this->duration)) {
return $this->duration;
}
throw new Exception('never get to getDuration SystemDbuffEmitter::duration');
}
/**
* @return int
*/
public static function sampleDuration(): int {
return 33; /*33:duration*/
}
/**
* @param bool $value
* @throws Exception
* @return bool
*/
public static function fromExcludeProtected(bool $value): bool {
return $value; /*bool*/
}
/**
* @throws Exception
* @return bool
*/
public function toExcludeProtected(): bool {
if (SystemDbuffEmitter::validateExcludeProtected($this->excludeProtected)) {
return $this->excludeProtected; /*bool*/
}
throw new Exception('never get to this SystemDbuffEmitter::excludeProtected');
}
/**
* @param bool
* @return bool
* @throws Exception
*/
public static function validateExcludeProtected(bool $value): bool {
if (!is_bool($value)) {
throw new Exception("Attribute Error:SystemDbuffEmitter::excludeProtected");
}
return true;
}
/**
* @throws Exception
* @return bool
*/
public function getExcludeProtected(): bool {
if (SystemDbuffEmitter::validateExcludeProtected($this->excludeProtected)) {
return $this->excludeProtected;
}
throw new Exception('never get to getExcludeProtected SystemDbuffEmitter::excludeProtected');
}
/**
* @return bool
*/
public static function sampleExcludeProtected(): bool {
return true; /*34:excludeProtected*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromInterval(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toInterval(): int {
if (SystemDbuffEmitter::validateInterval($this->interval)) {
return $this->interval; /*int*/
}
throw new Exception('never get to this SystemDbuffEmitter::interval');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateInterval(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:SystemDbuffEmitter::interval");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getInterval(): int {
if (SystemDbuffEmitter::validateInterval($this->interval)) {
return $this->interval;
}
throw new Exception('never get to getInterval SystemDbuffEmitter::interval');
}
/**
* @return int
*/
public static function sampleInterval(): int {
return 35; /*35:interval*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return SystemDbuffEmitter::validateKey($this->key)
|| SystemDbuffEmitter::validateDbuffs($this->dbuffs)
|| SystemDbuffEmitter::validateDuration($this->duration)
|| SystemDbuffEmitter::validateExcludeProtected($this->excludeProtected)
|| SystemDbuffEmitter::validateInterval($this->interval);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'dbuffs'} = $this->toDbuffs();
$out->{'duration'} = $this->toDuration();
$out->{'excludeProtected'} = $this->toExcludeProtected();
$out->{'interval'} = $this->toInterval();
return $out;
}
/**
* @param stdClass $obj
* @return SystemDbuffEmitter
* @throws Exception
*/
public static function from(stdClass $obj): SystemDbuffEmitter {
return new SystemDbuffEmitter(
SystemDbuffEmitter::fromKey($obj->{'_key'})
,SystemDbuffEmitter::fromDbuffs($obj->{'dbuffs'})
,SystemDbuffEmitter::fromDuration($obj->{'duration'})
,SystemDbuffEmitter::fromExcludeProtected($obj->{'excludeProtected'})
,SystemDbuffEmitter::fromInterval($obj->{'interval'})
);
}
/**
* @return SystemDbuffEmitter
*/
public static function sample(): SystemDbuffEmitter {
return new SystemDbuffEmitter(
SystemDbuffEmitter::sampleKey()
,SystemDbuffEmitter::sampleDbuffs()
,SystemDbuffEmitter::sampleDuration()
,SystemDbuffEmitter::sampleExcludeProtected()
,SystemDbuffEmitter::sampleInterval()
);
}
}
// This is an autogenerated file:Dbuff
class Dbuff {
private int $key; // json:_key Required
private float $value; // json:_value Required
/**
* @param int $key
* @param float $value
*/
public function __construct(int $key, float $value) {
$this->key = $key;
$this->value = $value;
}
/**
* @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 (Dbuff::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this Dbuff::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Dbuff::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (Dbuff::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey Dbuff::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromValue(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toValue(): float {
if (Dbuff::validateValue($this->value)) {
return $this->value; /*float*/
}
throw new Exception('never get to this Dbuff::value');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateValue(float $value): bool {
if (!is_float($value) && !is_int($value)) {
throw new Exception("Attribute Error:Dbuff::value");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getValue(): float {
if (Dbuff::validateValue($this->value)) {
return $this->value;
}
throw new Exception('never get to getValue Dbuff::value');
}
/**
* @return float
*/
public static function sampleValue(): float {
return 32.032; /*32:value*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return Dbuff::validateKey($this->key)
|| Dbuff::validateValue($this->value);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'_value'} = $this->toValue();
return $out;
}
/**
* @param stdClass $obj
* @return Dbuff
* @throws Exception
*/
public static function from(stdClass $obj): Dbuff {
return new Dbuff(
Dbuff::fromKey($obj->{'_key'})
,Dbuff::fromValue($obj->{'_value'})
);
}
/**
* @return Dbuff
*/
public static function sample(): Dbuff {
return new Dbuff(
Dbuff::sampleKey()
,Dbuff::sampleValue()
);
}
}
from dataclasses import dataclass
from typing import 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_float(x: Any) -> float:
assert isinstance(x, (float, int)) and not isinstance(x, bool)
return float(x)
def to_float(x: Any) -> float:
assert isinstance(x, (int, float))
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 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()
@dataclass
class Dbuff:
key: int
value: float
@staticmethod
def from_dict(obj: Any) -> 'Dbuff':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
value = from_float(obj.get("_value"))
return Dbuff(key, value)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["_value"] = to_float(self.value)
return result
@dataclass
class SystemDbuffEmitter:
key: int
dbuffs: list[Dbuff]
duration: int
exclude_protected: bool
interval: int
@staticmethod
def from_dict(obj: Any) -> 'SystemDbuffEmitter':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
dbuffs = from_list(Dbuff.from_dict, obj.get("dbuffs"))
duration = from_int(obj.get("duration"))
exclude_protected = from_bool(obj.get("excludeProtected"))
interval = from_int(obj.get("interval"))
return SystemDbuffEmitter(key, dbuffs, duration, exclude_protected, interval)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["dbuffs"] = from_list(lambda x: to_class(Dbuff, x), self.dbuffs)
result["duration"] = from_int(self.duration)
result["excludeProtected"] = from_bool(self.exclude_protected)
result["interval"] = from_int(self.interval)
return result
def system_dbuff_emitter_from_dict(s: Any) -> SystemDbuffEmitter:
return SystemDbuffEmitter.from_dict(s)
def system_dbuff_emitter_to_dict(x: SystemDbuffEmitter) -> Any:
return to_class(SystemDbuffEmitter, x)
// To parse this data:
//
// import { Convert, SystemDbuffEmitter } from "./SystemDbuffEmitter";
//
// const systemDbuffEmitter = Convert.toSystemDbuffEmitter(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface SystemDbuffEmitter {
_key: number;
dbuffs: [Dbuff, ...Dbuff[]];
duration: number;
excludeProtected: boolean;
interval: number;
[property: string]: unknown;
}
export interface Dbuff {
_key: number;
_value: number;
[property: string]: unknown;
}
// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
public static toSystemDbuffEmitter(json: string): SystemDbuffEmitter {
return cast(JSON.parse(json), r("SystemDbuffEmitter"));
}
public static systemDbuffEmitterToJson(value: SystemDbuffEmitter): string {
return JSON.stringify(uncast(value, r("SystemDbuffEmitter")), 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 = {
"SystemDbuffEmitter": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "dbuffs", js: "dbuffs", typ: a(r("Dbuff")) },
{ json: "duration", js: "duration", typ: 0 },
{ json: "excludeProtected", js: "excludeProtected", typ: true },
{ json: "interval", js: "interval", typ: 0 },
], "any"),
"Dbuff": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "_value", js: "_value", typ: 3.14 },
], "any"),
};