mapSecondarySuns.jsonl
Schema
_key(required): integer
Range: 40455847 .. 40488502effectBeaconTypeID(required): integer
Range: 30844 .. 30884-
position(required): objectx(required): number
Range: -27566703854688.71 .. 24643180854664.258y(required): number
Range: -25834208001805.266 .. 24610542535881.15z(required): number
Range: -32090412251446.59 .. 21096262115330.047
-
solarSystemID(required): integer
Range: 31000001 .. 31002604 typeID(required): integer
Range: 30574 .. 30670
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var mapSecondarySun = MapSecondarySun.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class MapSecondarySun
{
[JsonProperty("_key")]
public long Key { get; set; }
[JsonProperty("effectBeaconTypeID")]
public long EffectBeaconTypeId { get; set; }
[JsonProperty("position")]
public Position Position { get; set; }
[JsonProperty("solarSystemID")]
public long SolarSystemId { get; set; }
[JsonProperty("typeID")]
public long TypeId { get; set; }
}
public partial class Position
{
[JsonProperty("x")]
[JsonConverter(typeof(PurpleMinMaxValueCheckConverter))]
public double X { get; set; }
[JsonProperty("y")]
[JsonConverter(typeof(FluffyMinMaxValueCheckConverter))]
public double Y { get; set; }
[JsonProperty("z")]
[JsonConverter(typeof(TentacledMinMaxValueCheckConverter))]
public double Z { get; set; }
}
public partial class MapSecondarySun
{
public static MapSecondarySun FromJson(string json) => JsonConvert.DeserializeObject<MapSecondarySun>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this MapSecondarySun 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 PurpleMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= -27566703854688.71 && value <= 24643180854664.258)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= -27566703854688.71 && value <= 24643180854664.258)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly PurpleMinMaxValueCheckConverter Singleton = new PurpleMinMaxValueCheckConverter();
}
internal class FluffyMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= -25834208001805.266 && value <= 24610542535881.15)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= -25834208001805.266 && value <= 24610542535881.15)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly FluffyMinMaxValueCheckConverter Singleton = new FluffyMinMaxValueCheckConverter();
}
internal class TentacledMinMaxValueCheckConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(double) || t == typeof(double?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<double>(reader);
if (value >= -32090412251446.59 && value <= 21096262115330.047)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (double)untypedValue;
if (value >= -32090412251446.59 && value <= 21096262115330.047)
{
serializer.Serialize(writer, value);
return;
}
throw new Exception("Cannot marshal type double");
}
public static readonly TentacledMinMaxValueCheckConverter Singleton = new TentacledMinMaxValueCheckConverter();
}
}
// 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:
//
// mapSecondarySun, err := UnmarshalMapSecondarySun(bytes)
// bytes, err = mapSecondarySun.Marshal()
package model
import "encoding/json"
func UnmarshalMapSecondarySun(data []byte) (MapSecondarySun, error) {
var r MapSecondarySun
err := json.Unmarshal(data, &r)
return r, err
}
func (r *MapSecondarySun) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type MapSecondarySun struct {
Key int64 `json:"_key"`
EffectBeaconTypeID int64 `json:"effectBeaconTypeID"`
Position Position `json:"position"`
SolarSystemID int64 `json:"solarSystemID"`
TypeID int64 `json:"typeID"`
}
type Position struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Z float64 `json:"z"`
}
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"_key":{"type":"integer","minimum":40455847,"maximum":40488502},"effectBeaconTypeID":{"type":"integer","minimum":30844,"maximum":30884},"position":{"type":"object","properties":{"x":{"type":"number","minimum":-2.756670385468871E13,"maximum":2.4643180854664258E13},"y":{"type":"number","minimum":-2.5834208001805266E13,"maximum":2.461054253588115E13},"z":{"type":"number","minimum":-3.209041225144659E13,"maximum":2.1096262115330047E13}},"required":["x","y","z"]},"solarSystemID":{"type":"integer","minimum":31000001,"maximum":31002604},"typeID":{"type":"integer","minimum":30574,"maximum":30670}},"required":["_key","effectBeaconTypeID","position","solarSystemID","typeID"]}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val mapSecondarySun = json.parse(MapSecondarySun.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class MapSecondarySun (
@SerialName("_key")
val key: Long,
@SerialName("effectBeaconTypeID")
val effectBeaconTypeId: Long,
val position: Position,
@SerialName("solarSystemID")
val solarSystemId: Long,
@SerialName("typeID")
val typeId: Long
)
@Serializable
data class Position (
val x: Double,
val y: Double,
val z: Double
)
<?php
// This is a autogenerated file:MapSecondarySun
class MapSecondarySun {
private int $key; // json:_key Required
private int $effectBeaconTypeId; // json:effectBeaconTypeID Required
private Position $position; // json:position Required
private int $solarSystemId; // json:solarSystemID Required
private int $typeId; // json:typeID Required
/**
* @param int $key
* @param int $effectBeaconTypeId
* @param Position $position
* @param int $solarSystemId
* @param int $typeId
*/
public function __construct(int $key, int $effectBeaconTypeId, Position $position, int $solarSystemId, int $typeId) {
$this->key = $key;
$this->effectBeaconTypeId = $effectBeaconTypeId;
$this->position = $position;
$this->solarSystemId = $solarSystemId;
$this->typeId = $typeId;
}
/**
* @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 (MapSecondarySun::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this MapSecondarySun::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:MapSecondarySun::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (MapSecondarySun::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey MapSecondarySun::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromEffectBeaconTypeId(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toEffectBeaconTypeId(): int {
if (MapSecondarySun::validateEffectBeaconTypeId($this->effectBeaconTypeId)) {
return $this->effectBeaconTypeId; /*int*/
}
throw new Exception('never get to this MapSecondarySun::effectBeaconTypeId');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateEffectBeaconTypeId(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:MapSecondarySun::effectBeaconTypeId");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getEffectBeaconTypeId(): int {
if (MapSecondarySun::validateEffectBeaconTypeId($this->effectBeaconTypeId)) {
return $this->effectBeaconTypeId;
}
throw new Exception('never get to getEffectBeaconTypeId MapSecondarySun::effectBeaconTypeId');
}
/**
* @return int
*/
public static function sampleEffectBeaconTypeId(): int {
return 32; /*32:effectBeaconTypeId*/
}
/**
* @param stdClass $value
* @throws Exception
* @return Position
*/
public static function fromPosition(stdClass $value): Position {
return Position::from($value); /*class*/
}
/**
* @throws Exception
* @return stdClass
*/
public function toPosition(): stdClass {
if (MapSecondarySun::validatePosition($this->position)) {
return $this->position->to(); /*class*/
}
throw new Exception('never get to this MapSecondarySun::position');
}
/**
* @param Position
* @return bool
* @throws Exception
*/
public static function validatePosition(Position $value): bool {
$value->validate();
return true;
}
/**
* @throws Exception
* @return Position
*/
public function getPosition(): Position {
if (MapSecondarySun::validatePosition($this->position)) {
return $this->position;
}
throw new Exception('never get to getPosition MapSecondarySun::position');
}
/**
* @return Position
*/
public static function samplePosition(): Position {
return Position::sample(); /*33:position*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromSolarSystemId(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toSolarSystemId(): int {
if (MapSecondarySun::validateSolarSystemId($this->solarSystemId)) {
return $this->solarSystemId; /*int*/
}
throw new Exception('never get to this MapSecondarySun::solarSystemId');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateSolarSystemId(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:MapSecondarySun::solarSystemId");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getSolarSystemId(): int {
if (MapSecondarySun::validateSolarSystemId($this->solarSystemId)) {
return $this->solarSystemId;
}
throw new Exception('never get to getSolarSystemId MapSecondarySun::solarSystemId');
}
/**
* @return int
*/
public static function sampleSolarSystemId(): int {
return 34; /*34:solarSystemId*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromTypeId(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toTypeId(): int {
if (MapSecondarySun::validateTypeId($this->typeId)) {
return $this->typeId; /*int*/
}
throw new Exception('never get to this MapSecondarySun::typeId');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateTypeId(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:MapSecondarySun::typeId");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getTypeId(): int {
if (MapSecondarySun::validateTypeId($this->typeId)) {
return $this->typeId;
}
throw new Exception('never get to getTypeId MapSecondarySun::typeId');
}
/**
* @return int
*/
public static function sampleTypeId(): int {
return 35; /*35:typeId*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return MapSecondarySun::validateKey($this->key)
|| MapSecondarySun::validateEffectBeaconTypeId($this->effectBeaconTypeId)
|| MapSecondarySun::validatePosition($this->position)
|| MapSecondarySun::validateSolarSystemId($this->solarSystemId)
|| MapSecondarySun::validateTypeId($this->typeId);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'effectBeaconTypeID'} = $this->toEffectBeaconTypeId();
$out->{'position'} = $this->toPosition();
$out->{'solarSystemID'} = $this->toSolarSystemId();
$out->{'typeID'} = $this->toTypeId();
return $out;
}
/**
* @param stdClass $obj
* @return MapSecondarySun
* @throws Exception
*/
public static function from(stdClass $obj): MapSecondarySun {
return new MapSecondarySun(
MapSecondarySun::fromKey($obj->{'_key'})
,MapSecondarySun::fromEffectBeaconTypeId($obj->{'effectBeaconTypeID'})
,MapSecondarySun::fromPosition($obj->{'position'})
,MapSecondarySun::fromSolarSystemId($obj->{'solarSystemID'})
,MapSecondarySun::fromTypeId($obj->{'typeID'})
);
}
/**
* @return MapSecondarySun
*/
public static function sample(): MapSecondarySun {
return new MapSecondarySun(
MapSecondarySun::sampleKey()
,MapSecondarySun::sampleEffectBeaconTypeId()
,MapSecondarySun::samplePosition()
,MapSecondarySun::sampleSolarSystemId()
,MapSecondarySun::sampleTypeId()
);
}
}
// This is a autogenerated file:Position
class Position {
private float $x; // json:x Required
private float $y; // json:y Required
private float $z; // json:z Required
/**
* @param float $x
* @param float $y
* @param float $z
*/
public function __construct(float $x, float $y, float $z) {
$this->x = $x;
$this->y = $y;
$this->z = $z;
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromX(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toX(): float {
if (Position::validateX($this->x)) {
return $this->x; /*float*/
}
throw new Exception('never get to this Position::x');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateX(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:Position::x");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getX(): float {
if (Position::validateX($this->x)) {
return $this->x;
}
throw new Exception('never get to getX Position::x');
}
/**
* @return float
*/
public static function sampleX(): float {
return 31.031; /*31:x*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromY(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toY(): float {
if (Position::validateY($this->y)) {
return $this->y; /*float*/
}
throw new Exception('never get to this Position::y');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateY(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:Position::y");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getY(): float {
if (Position::validateY($this->y)) {
return $this->y;
}
throw new Exception('never get to getY Position::y');
}
/**
* @return float
*/
public static function sampleY(): float {
return 32.032; /*32:y*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromZ(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toZ(): float {
if (Position::validateZ($this->z)) {
return $this->z; /*float*/
}
throw new Exception('never get to this Position::z');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateZ(float $value): bool {
if (!is_float($value)) {
throw new Exception("Attribute Error:Position::z");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getZ(): float {
if (Position::validateZ($this->z)) {
return $this->z;
}
throw new Exception('never get to getZ Position::z');
}
/**
* @return float
*/
public static function sampleZ(): float {
return 33.033; /*33:z*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return Position::validateX($this->x)
|| Position::validateY($this->y)
|| Position::validateZ($this->z);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'x'} = $this->toX();
$out->{'y'} = $this->toY();
$out->{'z'} = $this->toZ();
return $out;
}
/**
* @param stdClass $obj
* @return Position
* @throws Exception
*/
public static function from(stdClass $obj): Position {
return new Position(
Position::fromX($obj->{'x'})
,Position::fromY($obj->{'y'})
,Position::fromZ($obj->{'z'})
);
}
/**
* @return Position
*/
public static function sample(): Position {
return new Position(
Position::sampleX()
,Position::sampleY()
,Position::sampleZ()
);
}
}
from typing import Any, TypeVar, Type, cast
T = TypeVar("T")
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_int(x: Any) -> int:
assert isinstance(x, int) and not isinstance(x, bool)
return x
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
class Position:
x: float
y: float
z: float
def __init__(self, x: float, y: float, z: float) -> None:
self.x = x
self.y = y
self.z = z
@staticmethod
def from_dict(obj: Any) -> 'Position':
assert isinstance(obj, dict)
x = from_float(obj.get("x"))
y = from_float(obj.get("y"))
z = from_float(obj.get("z"))
return Position(x, y, z)
def to_dict(self) -> dict:
result: dict = {}
result["x"] = to_float(self.x)
result["y"] = to_float(self.y)
result["z"] = to_float(self.z)
return result
class MapSecondarySun:
key: int
effect_beacon_type_id: int
position: Position
solar_system_id: int
type_id: int
def __init__(self, key: int, effect_beacon_type_id: int, position: Position, solar_system_id: int, type_id: int) -> None:
self.key = key
self.effect_beacon_type_id = effect_beacon_type_id
self.position = position
self.solar_system_id = solar_system_id
self.type_id = type_id
@staticmethod
def from_dict(obj: Any) -> 'MapSecondarySun':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
effect_beacon_type_id = from_int(obj.get("effectBeaconTypeID"))
position = Position.from_dict(obj.get("position"))
solar_system_id = from_int(obj.get("solarSystemID"))
type_id = from_int(obj.get("typeID"))
return MapSecondarySun(key, effect_beacon_type_id, position, solar_system_id, type_id)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["effectBeaconTypeID"] = from_int(self.effect_beacon_type_id)
result["position"] = to_class(Position, self.position)
result["solarSystemID"] = from_int(self.solar_system_id)
result["typeID"] = from_int(self.type_id)
return result
def map_secondary_sun_from_dict(s: Any) -> MapSecondarySun:
return MapSecondarySun.from_dict(s)
def map_secondary_sun_to_dict(x: MapSecondarySun) -> Any:
return to_class(MapSecondarySun, x)
// To parse this data:
//
// import { Convert, MapSecondarySun } from "./file";
//
// const mapSecondarySun = Convert.toMapSecondarySun(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface MapSecondarySun {
_key: number;
effectBeaconTypeID: number;
position: Position;
solarSystemID: number;
typeID: number;
[property: string]: any;
}
export interface Position {
x: number;
y: number;
z: 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 toMapSecondarySun(json: string): MapSecondarySun {
return cast(JSON.parse(json), r("MapSecondarySun"));
}
public static mapSecondarySunToJson(value: MapSecondarySun): string {
return JSON.stringify(uncast(value, r("MapSecondarySun")), 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 = {
"MapSecondarySun": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "effectBeaconTypeID", js: "effectBeaconTypeID", typ: 0 },
{ json: "position", js: "position", typ: r("Position") },
{ json: "solarSystemID", js: "solarSystemID", typ: 0 },
{ json: "typeID", js: "typeID", typ: 0 },
], "any"),
"Position": o([
{ json: "x", js: "x", typ: 3.14 },
{ json: "y", js: "y", typ: 3.14 },
{ json: "z", js: "z", typ: 3.14 },
], "any"),
};