metenoxMoonDrill.jsonl
Schema
_key(required): integer
Range: 81826 .. 81826miningCycleTime(required): integer
Range: 3600 .. 3600miningEfficiency(required): number
Range: 0.4 .. 0.4reagentsConsumedPerCycle(required): integer
Range: 200 .. 200
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'System.Text.Json' then do:
//
// using QuickType;
//
// var metenoxMoonDrill = MetenoxMoonDrill.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 MetenoxMoonDrill
{
[JsonPropertyName("_key")]
public long Key { get; set; }
[JsonPropertyName("miningCycleTime")]
public long MiningCycleTime { get; set; }
[JsonPropertyName("miningEfficiency")]
[JsonConverter(typeof(MinMaxValueCheckConverter))]
public double MiningEfficiency { get; set; }
[JsonPropertyName("reagentsConsumedPerCycle")]
public long ReagentsConsumedPerCycle { get; set; }
}
public partial class MetenoxMoonDrill
{
public static MetenoxMoonDrill FromJson(string json) => JsonSerializer.Deserialize<MetenoxMoonDrill>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this MetenoxMoonDrill 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 >= 0.4 && value <= 0.4)
{
return value;
}
throw new Exception("Cannot unmarshal type double");
}
public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options)
{
if (value >= 0.4 && value <= 0.4)
{
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:
//
// metenoxMoonDrill, err := UnmarshalMetenoxMoonDrill(bytes)
// bytes, err = metenoxMoonDrill.Marshal()
package model
import "encoding/json"
func UnmarshalMetenoxMoonDrill(data []byte) (MetenoxMoonDrill, error) {
var r MetenoxMoonDrill
err := json.Unmarshal(data, &r)
return r, err
}
func (r *MetenoxMoonDrill) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type MetenoxMoonDrill struct {
Key int64 `json:"_key"`
MiningCycleTime int64 `json:"miningCycleTime"`
MiningEfficiency float64 `json:"miningEfficiency"`
ReagentsConsumedPerCycle int64 `json:"reagentsConsumedPerCycle"`
}
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"_key":{"type":"integer","minimum":81826,"maximum":81826},"miningCycleTime":{"type":"integer","minimum":3600,"maximum":3600},"miningEfficiency":{"type":"number","minimum":0.4,"maximum":0.4},"reagentsConsumedPerCycle":{"type":"integer","minimum":200,"maximum":200}},"required":["_key","miningCycleTime","miningEfficiency","reagentsConsumedPerCycle"]}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val metenoxMoonDrill = json.parse(MetenoxMoonDrill.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class MetenoxMoonDrill (
@SerialName("_key")
val key: Long,
val miningCycleTime: Long,
val miningEfficiency: Double,
val reagentsConsumedPerCycle: Long
)
<?php
// This is an autogenerated file:MetenoxMoonDrill
class MetenoxMoonDrill {
private int $key; // json:_key Required
private int $miningCycleTime; // json:miningCycleTime Required
private float $miningEfficiency; // json:miningEfficiency Required
private int $reagentsConsumedPerCycle; // json:reagentsConsumedPerCycle Required
/**
* @param int $key
* @param int $miningCycleTime
* @param float $miningEfficiency
* @param int $reagentsConsumedPerCycle
*/
public function __construct(int $key, int $miningCycleTime, float $miningEfficiency, int $reagentsConsumedPerCycle) {
$this->key = $key;
$this->miningCycleTime = $miningCycleTime;
$this->miningEfficiency = $miningEfficiency;
$this->reagentsConsumedPerCycle = $reagentsConsumedPerCycle;
}
/**
* @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 (MetenoxMoonDrill::validateKey($this->key)) {
return $this->key; /*int*/
}
throw new Exception('never get to this MetenoxMoonDrill::key');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateKey(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:MetenoxMoonDrill::key");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getKey(): int {
if (MetenoxMoonDrill::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey MetenoxMoonDrill::key');
}
/**
* @return int
*/
public static function sampleKey(): int {
return 31; /*31:key*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromMiningCycleTime(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toMiningCycleTime(): int {
if (MetenoxMoonDrill::validateMiningCycleTime($this->miningCycleTime)) {
return $this->miningCycleTime; /*int*/
}
throw new Exception('never get to this MetenoxMoonDrill::miningCycleTime');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateMiningCycleTime(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:MetenoxMoonDrill::miningCycleTime");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getMiningCycleTime(): int {
if (MetenoxMoonDrill::validateMiningCycleTime($this->miningCycleTime)) {
return $this->miningCycleTime;
}
throw new Exception('never get to getMiningCycleTime MetenoxMoonDrill::miningCycleTime');
}
/**
* @return int
*/
public static function sampleMiningCycleTime(): int {
return 32; /*32:miningCycleTime*/
}
/**
* @param float $value
* @throws Exception
* @return float
*/
public static function fromMiningEfficiency(float $value): float {
return $value; /*float*/
}
/**
* @throws Exception
* @return float
*/
public function toMiningEfficiency(): float {
if (MetenoxMoonDrill::validateMiningEfficiency($this->miningEfficiency)) {
return $this->miningEfficiency; /*float*/
}
throw new Exception('never get to this MetenoxMoonDrill::miningEfficiency');
}
/**
* @param float
* @return bool
* @throws Exception
*/
public static function validateMiningEfficiency(float $value): bool {
if (!is_float($value) && !is_int($value)) {
throw new Exception("Attribute Error:MetenoxMoonDrill::miningEfficiency");
}
return true;
}
/**
* @throws Exception
* @return float
*/
public function getMiningEfficiency(): float {
if (MetenoxMoonDrill::validateMiningEfficiency($this->miningEfficiency)) {
return $this->miningEfficiency;
}
throw new Exception('never get to getMiningEfficiency MetenoxMoonDrill::miningEfficiency');
}
/**
* @return float
*/
public static function sampleMiningEfficiency(): float {
return 33.033; /*33:miningEfficiency*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromReagentsConsumedPerCycle(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toReagentsConsumedPerCycle(): int {
if (MetenoxMoonDrill::validateReagentsConsumedPerCycle($this->reagentsConsumedPerCycle)) {
return $this->reagentsConsumedPerCycle; /*int*/
}
throw new Exception('never get to this MetenoxMoonDrill::reagentsConsumedPerCycle');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateReagentsConsumedPerCycle(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:MetenoxMoonDrill::reagentsConsumedPerCycle");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getReagentsConsumedPerCycle(): int {
if (MetenoxMoonDrill::validateReagentsConsumedPerCycle($this->reagentsConsumedPerCycle)) {
return $this->reagentsConsumedPerCycle;
}
throw new Exception('never get to getReagentsConsumedPerCycle MetenoxMoonDrill::reagentsConsumedPerCycle');
}
/**
* @return int
*/
public static function sampleReagentsConsumedPerCycle(): int {
return 34; /*34:reagentsConsumedPerCycle*/
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return MetenoxMoonDrill::validateKey($this->key)
|| MetenoxMoonDrill::validateMiningCycleTime($this->miningCycleTime)
|| MetenoxMoonDrill::validateMiningEfficiency($this->miningEfficiency)
|| MetenoxMoonDrill::validateReagentsConsumedPerCycle($this->reagentsConsumedPerCycle);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'miningCycleTime'} = $this->toMiningCycleTime();
$out->{'miningEfficiency'} = $this->toMiningEfficiency();
$out->{'reagentsConsumedPerCycle'} = $this->toReagentsConsumedPerCycle();
return $out;
}
/**
* @param stdClass $obj
* @return MetenoxMoonDrill
* @throws Exception
*/
public static function from(stdClass $obj): MetenoxMoonDrill {
return new MetenoxMoonDrill(
MetenoxMoonDrill::fromKey($obj->{'_key'})
,MetenoxMoonDrill::fromMiningCycleTime($obj->{'miningCycleTime'})
,MetenoxMoonDrill::fromMiningEfficiency($obj->{'miningEfficiency'})
,MetenoxMoonDrill::fromReagentsConsumedPerCycle($obj->{'reagentsConsumedPerCycle'})
);
}
/**
* @return MetenoxMoonDrill
*/
public static function sample(): MetenoxMoonDrill {
return new MetenoxMoonDrill(
MetenoxMoonDrill::sampleKey()
,MetenoxMoonDrill::sampleMiningCycleTime()
,MetenoxMoonDrill::sampleMiningEfficiency()
,MetenoxMoonDrill::sampleReagentsConsumedPerCycle()
);
}
}
from dataclasses import dataclass
from typing import Any, TypeVar, 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 to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
@dataclass
class MetenoxMoonDrill:
key: int
mining_cycle_time: int
mining_efficiency: float
reagents_consumed_per_cycle: int
@staticmethod
def from_dict(obj: Any) -> 'MetenoxMoonDrill':
assert isinstance(obj, dict)
key = from_int(obj.get("_key"))
mining_cycle_time = from_int(obj.get("miningCycleTime"))
mining_efficiency = from_float(obj.get("miningEfficiency"))
reagents_consumed_per_cycle = from_int(obj.get("reagentsConsumedPerCycle"))
return MetenoxMoonDrill(key, mining_cycle_time, mining_efficiency, reagents_consumed_per_cycle)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = from_int(self.key)
result["miningCycleTime"] = from_int(self.mining_cycle_time)
result["miningEfficiency"] = to_float(self.mining_efficiency)
result["reagentsConsumedPerCycle"] = from_int(self.reagents_consumed_per_cycle)
return result
def metenox_moon_drill_from_dict(s: Any) -> MetenoxMoonDrill:
return MetenoxMoonDrill.from_dict(s)
def metenox_moon_drill_to_dict(x: MetenoxMoonDrill) -> Any:
return to_class(MetenoxMoonDrill, x)
// To parse this data:
//
// import { Convert, MetenoxMoonDrill } from "./MetenoxMoonDrill";
//
// const metenoxMoonDrill = Convert.toMetenoxMoonDrill(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface MetenoxMoonDrill {
_key: number;
miningCycleTime: number;
miningEfficiency: number;
reagentsConsumedPerCycle: 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 toMetenoxMoonDrill(json: string): MetenoxMoonDrill {
return cast(JSON.parse(json), r("MetenoxMoonDrill"));
}
public static metenoxMoonDrillToJson(value: MetenoxMoonDrill): string {
return JSON.stringify(uncast(value, r("MetenoxMoonDrill")), 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 = {
"MetenoxMoonDrill": o([
{ json: "_key", js: "_key", typ: 0 },
{ json: "miningCycleTime", js: "miningCycleTime", typ: 0 },
{ json: "miningEfficiency", js: "miningEfficiency", typ: 3.14 },
{ json: "reagentsConsumedPerCycle", js: "reagentsConsumedPerCycle", typ: 0 },
], "any"),
};