﻿//----------------------
// <auto-generated>
// </auto-generated>
//----------------------







export class MyClass implements IMyClass {
    a!: { [key: string]: string; };
    b!: { [key: string]: string; } | undefined;

    [key: string]: any;

    constructor(data?: IMyClass) {
        if (data) {
            for (var property in data) {
                if (data.hasOwnProperty(property))
                    (this as any)[property] = (data as any)[property];
            }
        }
        if (!data) {
            this.a = {};
        }
    }

    init(_data?: any) {
        if (_data) {
            for (var property in _data) {
                if (_data.hasOwnProperty(property))
                    this[property] = _data[property];
            }
            if (_data["A"]) {
                this.a = {} as any;
                for (let key in _data["A"]) {
                    if (_data["A"].hasOwnProperty(key))
                        (this.a as any)![key] = _data["A"][key];
                }
            }
            if (_data["B"]) {
                this.b = {} as any;
                for (let key in _data["B"]) {
                    if (_data["B"].hasOwnProperty(key))
                        (this.b as any)![key] = _data["B"][key];
                }
            }
        }
    }

    static fromJS(data: any): MyClass {
        data = typeof data === 'object' ? data : {};
        let result = new MyClass();
        result.init(data);
        return result;
    }

    toJSON(data?: any) {
        data = typeof data === 'object' ? data : {};
        for (var property in this) {
            if (this.hasOwnProperty(property))
                data[property] = this[property];
        }
        if (this.a) {
            data["A"] = {};
            for (let key in this.a) {
                if (this.a.hasOwnProperty(key))
                    (data["A"] as any)[key] = (this.a as any)[key];
            }
        }
        if (this.b) {
            data["B"] = {};
            for (let key in this.b) {
                if (this.b.hasOwnProperty(key))
                    (data["B"] as any)[key] = (this.b as any)[key];
            }
        }
        return data;
    }
}

export interface IMyClass {
    a: { [key: string]: string; };
    b: { [key: string]: string; } | undefined;

    [key: string]: any;
}