_sde.jsonl
Schema
_key
(required): enum
Enum values:sde
buildNumber
(required): integer
Range: 3031812 .. 3031812releaseDate
(required): string
Format: date-time
Code snippets
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using QuickType;
//
// var sde = Sde.FromJson(jsonString);
namespace QuickType
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
public partial class Sde
{
[JsonProperty("_key")]
public Key Key { get; set; }
[JsonProperty("buildNumber")]
public long BuildNumber { get; set; }
[JsonProperty("releaseDate")]
public DateTimeOffset ReleaseDate { get; set; }
}
public enum Key { Sde };
public partial class Sde
{
public static Sde FromJson(string json) => JsonConvert.DeserializeObject<Sde>(json, QuickType.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this Sde 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 =
{
KeyConverter.Singleton,
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
internal class KeyConverter : JsonConverter
{
public override bool CanConvert(Type t) => t == typeof(Key) || t == typeof(Key?);
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var value = serializer.Deserialize<string>(reader);
if (value == "sde")
{
return Key.Sde;
}
throw new Exception("Cannot unmarshal type Key");
}
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
{
if (untypedValue == null)
{
serializer.Serialize(writer, null);
return;
}
var value = (Key)untypedValue;
if (value == Key.Sde)
{
serializer.Serialize(writer, "sde");
return;
}
throw new Exception("Cannot marshal type Key");
}
public static readonly KeyConverter Singleton = new KeyConverter();
}
}
// 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:
//
// sde, err := UnmarshalSde(bytes)
// bytes, err = sde.Marshal()
package model
import "time"
import "encoding/json"
func UnmarshalSde(data []byte) (Sde, error) {
var r Sde
err := json.Unmarshal(data, &r)
return r, err
}
func (r *Sde) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type Sde struct {
Key Key `json:"_key"`
BuildNumber int64 `json:"buildNumber"`
ReleaseDate time.Time `json:"releaseDate"`
}
type Key string
const (
KeySde Key = "sde"
)
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"_key": {
"type": "string",
"enum": [
"sde"
]
},
"buildNumber": {
"type": "integer",
"minimum": 3031812,
"maximum": 3031812
},
"releaseDate": {
"type": "string",
"format": "date-time",
"minLength": 20,
"maxLength": 20
}
},
"required": [
"_key",
"buildNumber",
"releaseDate"
]
}
// To parse the JSON, install kotlin's serialization plugin and do:
//
// val json = Json { allowStructuredMapKeys = true }
// val sde = json.parse(Sde.serializer(), jsonString)
package model
import kotlinx.serialization.*
import kotlinx.serialization.json.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
@Serializable
data class Sde (
@SerialName("_key")
val key: Key,
val buildNumber: Long,
val releaseDate: String
)
@Serializable
enum class Key(val value: String) {
@SerialName("sde") Sde("sde");
}
<?php
// This is a autogenerated file:Sde
class Sde {
private Key $key; // json:_key Required
private int $buildNumber; // json:buildNumber Required
private DateTime $releaseDate; // json:releaseDate Required
/**
* @param Key $key
* @param int $buildNumber
* @param DateTime $releaseDate
*/
public function __construct(Key $key, int $buildNumber, DateTime $releaseDate) {
$this->key = $key;
$this->buildNumber = $buildNumber;
$this->releaseDate = $releaseDate;
}
/**
* @param string $value
* @throws Exception
* @return Key
*/
public static function fromKey(string $value): Key {
return Key::from($value); /*enum*/
}
/**
* @throws Exception
* @return string
*/
public function toKey(): string {
if (Sde::validateKey($this->key)) {
return Key::to($this->key); /*enum*/
}
throw new Exception('never get to this Sde::key');
}
/**
* @param Key
* @return bool
* @throws Exception
*/
public static function validateKey(Key $value): bool {
Key::to($value);
return true;
}
/**
* @throws Exception
* @return Key
*/
public function getKey(): Key {
if (Sde::validateKey($this->key)) {
return $this->key;
}
throw new Exception('never get to getKey Sde::key');
}
/**
* @return Key
*/
public static function sampleKey(): Key {
return Key::sample(); /*enum*/
}
/**
* @param int $value
* @throws Exception
* @return int
*/
public static function fromBuildNumber(int $value): int {
return $value; /*int*/
}
/**
* @throws Exception
* @return int
*/
public function toBuildNumber(): int {
if (Sde::validateBuildNumber($this->buildNumber)) {
return $this->buildNumber; /*int*/
}
throw new Exception('never get to this Sde::buildNumber');
}
/**
* @param int
* @return bool
* @throws Exception
*/
public static function validateBuildNumber(int $value): bool {
if (!is_integer($value)) {
throw new Exception("Attribute Error:Sde::buildNumber");
}
return true;
}
/**
* @throws Exception
* @return int
*/
public function getBuildNumber(): int {
if (Sde::validateBuildNumber($this->buildNumber)) {
return $this->buildNumber;
}
throw new Exception('never get to getBuildNumber Sde::buildNumber');
}
/**
* @return int
*/
public static function sampleBuildNumber(): int {
return 32; /*32:buildNumber*/
}
/**
* @param string $value
* @throws Exception
* @return DateTime
*/
public static function fromReleaseDate(string $value): DateTime {
$tmp = DateTime::createFromFormat(DateTimeInterface::ISO8601, $value);
if (!is_a($tmp, 'DateTime')) {
throw new Exception('Attribute Error:Sde::');
}
return $tmp;
}
/**
* @throws Exception
* @return string
*/
public function toReleaseDate(): string {
if (Sde::validateReleaseDate($this->releaseDate)) {
return $this->releaseDate->format(DateTimeInterface::ISO8601);
}
throw new Exception('never get to this Sde::releaseDate');
}
/**
* @param DateTime
* @return bool
* @throws Exception
*/
public static function validateReleaseDate(DateTime $value): bool {
if (!is_a($value, 'DateTime')) {
throw new Exception('Attribute Error:Sde::releaseDate');
}
return true;
}
/**
* @throws Exception
* @return DateTime
*/
public function getReleaseDate(): DateTime {
if (Sde::validateReleaseDate($this->releaseDate)) {
return $this->releaseDate;
}
throw new Exception('never get to getReleaseDate Sde::releaseDate');
}
/**
* @return DateTime
*/
public static function sampleReleaseDate(): DateTime {
return DateTime::createFromFormat(DateTimeInterface::ISO8601, '2020-12-30T12:30:30+00:00');
}
/**
* @throws Exception
* @return bool
*/
public function validate(): bool {
return Sde::validateKey($this->key)
|| Sde::validateBuildNumber($this->buildNumber)
|| Sde::validateReleaseDate($this->releaseDate);
}
/**
* @return stdClass
* @throws Exception
*/
public function to(): stdClass {
$out = new stdClass();
$out->{'_key'} = $this->toKey();
$out->{'buildNumber'} = $this->toBuildNumber();
$out->{'releaseDate'} = $this->toReleaseDate();
return $out;
}
/**
* @param stdClass $obj
* @return Sde
* @throws Exception
*/
public static function from(stdClass $obj): Sde {
return new Sde(
Sde::fromKey($obj->{'_key'})
,Sde::fromBuildNumber($obj->{'buildNumber'})
,Sde::fromReleaseDate($obj->{'releaseDate'})
);
}
/**
* @return Sde
*/
public static function sample(): Sde {
return new Sde(
Sde::sampleKey()
,Sde::sampleBuildNumber()
,Sde::sampleReleaseDate()
);
}
}
// This is a autogenerated file:Key
class Key {
public static Key $SDE;
public static function init() {
Key::$SDE = new Key('sde');
}
private string $enum;
public function __construct(string $enum) {
$this->enum = $enum;
}
/**
* @param Key
* @return string
* @throws Exception
*/
public static function to(Key $obj): string {
switch ($obj->enum) {
case Key::$SDE->enum: return 'sde';
}
throw new Exception('the give value is not an enum-value.');
}
/**
* @param mixed
* @return Key
* @throws Exception
*/
public static function from($obj): Key {
switch ($obj) {
case 'sde': return Key::$SDE;
}
throw new Exception("Cannot deserialize Key");
}
/**
* @return Key
*/
public static function sample(): Key {
return Key::$SDE;
}
}
Key::init();
from enum import Enum
from datetime import datetime
from typing import Any, TypeVar, Type, cast
import dateutil.parser
T = TypeVar("T")
EnumT = TypeVar("EnumT", bound=Enum)
def from_int(x: Any) -> int:
assert isinstance(x, int) and not isinstance(x, bool)
return x
def from_datetime(x: Any) -> datetime:
return dateutil.parser.parse(x)
def to_enum(c: Type[EnumT], x: Any) -> EnumT:
assert isinstance(x, c)
return x.value
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
class Key(Enum):
SDE = "sde"
class Sde:
key: Key
build_number: int
release_date: datetime
def __init__(self, key: Key, build_number: int, release_date: datetime) -> None:
self.key = key
self.build_number = build_number
self.release_date = release_date
@staticmethod
def from_dict(obj: Any) -> 'Sde':
assert isinstance(obj, dict)
key = Key(obj.get("_key"))
build_number = from_int(obj.get("buildNumber"))
release_date = from_datetime(obj.get("releaseDate"))
return Sde(key, build_number, release_date)
def to_dict(self) -> dict:
result: dict = {}
result["_key"] = to_enum(Key, self.key)
result["buildNumber"] = from_int(self.build_number)
result["releaseDate"] = self.release_date.isoformat()
return result
def sde_from_dict(s: Any) -> Sde:
return Sde.from_dict(s)
def sde_to_dict(x: Sde) -> Any:
return to_class(Sde, x)
// To parse this data:
//
// import { Convert, Sde } from "./file";
//
// const sde = Convert.toSde(json);
//
// These functions will throw an error if the JSON doesn't
// match the expected interface, even if the JSON is valid.
export interface Sde {
_key: Key;
buildNumber: number;
releaseDate: Date;
[property: string]: any;
}
export enum Key {
Sde = "sde",
}
// Converts JSON strings to/from your types
// and asserts the results of JSON.parse at runtime
export class Convert {
public static toSde(json: string): Sde {
return cast(JSON.parse(json), r("Sde"));
}
public static sdeToJson(value: Sde): string {
return JSON.stringify(uncast(value, r("Sde")), 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 = {
"Sde": o([
{ json: "_key", js: "_key", typ: r("Key") },
{ json: "buildNumber", js: "buildNumber", typ: 0 },
{ json: "releaseDate", js: "releaseDate", typ: Date },
], "any"),
"Key": [
"sde",
],
};