"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatasetBind = void 0;
/* eslint-disable @typescript-eslint/no-explicit-any */
class DatasetBind {
    constructor(data) {
        this.data = data;
    }
    toJSON() {
        return this.objectToJSON(this.data);
    }
    objectToJSON(obj) {
        let str = '{';
        for (const key in obj) {
            if (Object.prototype.hasOwnProperty.call(obj, key)) {
                const element = obj[key];
                str += `${key}:`;
                if (typeof element === 'string') {
                    str += `${this.stringToJSON(element)}`;
                }
                else if (typeof element === 'number') {
                    str += `${this.numberToJSON(element)}`;
                }
                else if (element instanceof Array) {
                    str += `${this.arrayToJSON(element)}`;
                }
                else if (typeof element === 'object' && element !== null) {
                    str += `${this.objectToJSON(element)}`;
                }
                str += ',';
            }
        }
        str = str.substr(0, str.length - 1);
        str += '}';
        return str;
    }
    numberToJSON(number) {
        return `${number}`;
    }
    stringToJSON(string) {
        return `'${string}'`;
    }
    arrayToJSON(list) {
        let str = '[';
        for (let i = 0; i < list.length; i++) {
            const element = list[i];
            if (typeof element === 'string') {
                str += this.stringToJSON(element);
            }
            else if (typeof element === 'number') {
                str += this.numberToJSON(element);
            }
            else if (element instanceof Array) {
                str += this.arrayToJSON(element);
            }
            else if (typeof element === 'object' && element !== null) {
                str += this.objectToJSON(element);
            }
            if (i !== list.length - 1) {
                str += ',';
            }
        }
        str += ']';
        return str;
    }
}
exports.DatasetBind = DatasetBind;
