{"version":3,"file":"untypedjson.umd.cjs","sources":["../src/converters.ts","../src/helpers.ts","../src/decorators.ts","../src/types.ts","../src/features.ts"],"sourcesContent":["import {\r\n    type JsonType,\r\n} from './types';\r\n\r\n/**\r\n * A base class for JSON converters.\r\n *\r\n * When extending this class, you must implement the Serialize and Deserialize methods.\r\n * Type checking is not performed when using a custom converter.\r\n * @template T\r\n * @returns {JsonConverter<T>}\r\n * @class\r\n * @abstract\r\n * @example\r\n * class DateConverter extends JsonConverter<Date> {\r\n *   public Serialize (value: Date): string {\r\n *     return value.toISOString();\r\n *   }\r\n *   public Deserialize (value: string): Date {\r\n *     return new Date(value);\r\n *   }\r\n * }\r\n *\r\n * class MyClass {\r\n *   \\@JsonProperty('date', DateConverter)\r\n *   public date: Date;\r\n * }\r\n */\r\nexport abstract class JsonConverter<T> {\r\n    /**\r\n     * Serializes a value into a JSON object.\r\n     * @param {T} value\r\n     * @returns {any}\r\n     */\r\n    public abstract Serialize (value: T): any;\r\n\r\n    /**\r\n     * Deserializes a JSON object into a value.\r\n     * @param value\r\n     * @returns {T}\r\n     */\r\n    public abstract Deserialize (value: JsonType): T;\r\n}\r\n","import {\r\n    type IJsonClassMetadata,\r\n} from './types';\r\n\r\n/**\r\n * A unique symbol representing the key for accessing metadata in an object.\r\n */\r\nexport const MetadataKey = Symbol('UntypedJSONMetadata');\r\n\r\n/**\r\n * Retrieves or creates metadata for a class.\r\n * @param {Function} constructor - The class constructor.\r\n * @returns {IJsonClassMetadata} - The class metadata.\r\n */\r\nexport const GetOrCreateClassMetaData = (constructor: Function): IJsonClassMetadata => {\r\n    return constructor.hasOwnProperty(MetadataKey) ? constructor[MetadataKey] : Object.create({\r\n        mixins: [],\r\n        options: {},\r\n        properties: Object.create(null),\r\n    });\r\n};\r\n\r\n/**\r\n * Check if a given type is a built-in type (String, Number, Boolean).\r\n * @param {any} type - The type to check.\r\n * @returns {boolean} - True if the given type is a built-in type, false otherwise.\r\n */\r\nexport const isBuiltInType = (type: any): boolean => {\r\n    return type === String || type === Number || type === Boolean;\r\n};\r\n","import {\n    GetOrCreateClassMetaData,\n    isBuiltInType,\n    MetadataKey,\n} from './helpers';\nimport {\n    type BuiltInConstructorType,\n    type Constructor,\n    type DeserializeType,\n    type IJsonClassMetadata,\n    type IJsonClassOptions,\n    type IJsonPropertyMetadata,\n    type JsonType,\n    type PropertyNullability,\n} from './types';\n\n/**\n * Decorator for properties that should be serialized and deserialized.\n * @param {string} jsonProperty The name of the property in the JSON.\n * @param {DeserializeType} [type] The type of the property.\n * Can be a primitive type, a class, an array of either, or a JsonConverter.\n * Optional if a default value is provided, as it will infer the type from the default value.\n * @param {PropertyNullability} [nullabilityMode] The nullability mode of the property.\n * Defaults to PropertyNullability.MAP.\n * A different default can be set with the @JsonOptions decorator.\n * @example\n * class TestClass {\n *    \\@JsonProperty('test', JsonType.STRING)\n *    public test: string;\n *\n *    \\@JsonProperty('testArray', [JsonType.STRING])\n *    public testArray: string[] = [];\n * }\n */\nexport const JsonProperty = (jsonProperty: string, type?: DeserializeType, nullabilityMode?: PropertyNullability) => {\n    return function (target: any, propertyKey: string) {\n        const isArray = Array.isArray(type);\n        let isClass = false;\n        let classType: new() => any;\n        let processedType = type;\n\n        if (isBuiltInType(type) || isArray && isBuiltInType(type[0])) {\n            processedType = isArray ?\n                [(type[0] as BuiltInConstructorType).name?.toLowerCase()] as JsonType[] :\n                (type as BuiltInConstructorType).name?.toLowerCase() as JsonType;\n        } else {\n            isClass = isArray ? typeof type[0] === 'function' : typeof type === 'function';\n            classType = (isClass ? (isArray ? type[0] : type) : undefined) as new() => any;\n        }\n\n        const metadata: IJsonPropertyMetadata = {\n            array: isArray,\n            classType,\n            jsonProperty,\n            nested: isClass,\n            nullabilityMode,\n            type: processedType,\n        };\n\n        const targetConstructor = target.constructor;\n        const classMetadata: IJsonClassMetadata = GetOrCreateClassMetaData(targetConstructor);\n        classMetadata.properties[propertyKey] = metadata;\n        targetConstructor[MetadataKey] = classMetadata;\n    };\n};\n\n/**\n * Decorator for classes that should inherit (mix in) other classes.\n * @template T\n * @param {T} classes The classes to mix in.\n * @example\n * class Walkable {...}\n * class Flyable {...}\n *\n * \\@JsonMixin(Walkable, Flyable)\n * class Bird {\n *    \\@JsonProperty('name', JsonType.STRING)\n *    public name: string;\n * }\n */\nexport const JsonMixin = <T extends Constructor[]> (...classes: T) => {\n    return function <C extends Constructor>(target: C): void {\n        const classMetadata: IJsonClassMetadata = GetOrCreateClassMetaData(target);\n\n        classMetadata.mixins = classes;\n\n        target[MetadataKey] = classMetadata;\n    };\n};\n\n/**\n * Decorator function that applies JSON options to a class.\n * @param {IJsonClassOptions} options - The JSON options to apply.\n */\nexport const JsonOptions = (options: IJsonClassOptions) => {\n    return function <C extends Constructor>(target: C): void {\n        const classMetadata: IJsonClassMetadata = GetOrCreateClassMetaData(target);\n\n        classMetadata.options = options;\n\n        target[MetadataKey] = classMetadata;\n    };\n};\n","/* eslint-disable @typescript-eslint/no-shadow */\r\nimport {\r\n    type JsonConverter,\r\n} from './converters';\r\n\r\n/**\r\n * Represents the options for deserializing an object.\r\n * @property {boolean} [mapClassProperties=false] - Whether to try and map JSON properties to class names by default.\r\n * This means you don't need to use @JsonProperty if the property name is the same as the class name.\r\n * @property {boolean} [passUnknownProperties=false] - Determines whether unknown properties should be passed or ignored during deserialization from JSON.\r\n */\r\nexport type DeserializeOptions = {\r\n    mapClassProperties?: boolean,\r\n    passUnknownProperties?: boolean,\r\n};\r\n\r\n/**\r\n * Options for serializing objects.\r\n * @property {boolean} [passUnknownProperties=false] - Determines whether unknown properties should be passed or ignored during serialization to JSON.\r\n */\r\nexport type SerializeOptions = {\r\n    passUnknownProperties?: boolean,\r\n};\r\n\r\n/**\r\n * Represents a built-in constructor type in JavaScript.\r\n */\r\nexport type BuiltInConstructorType = StringConstructor | NumberConstructor | BooleanConstructor;\r\n\r\n/**\r\n * The type the JSON property is deserialized to.\r\n * This can be a primitive type using JsonType, a class, an array of either, or a custom JsonConverter.\r\n */\r\nexport type DeserializeType = Array<JsonConverter<any>> | Array<new() => any> | JsonConverter<any> | JsonType | JsonType[] | (new() => any) | BuiltInConstructorType | BuiltInConstructorType[];\r\n\r\n/**\r\n * The type of the constructor.\r\n */\r\nexport type Constructor<T = {}> = new (...args: any[]) => T;\r\n\r\n/**\r\n * The metadata for a JSON property.\r\n * @property {PropertyNullability} nullabilityMode - The nullability mode of the property.\r\n * @property {boolean} array - Whether the property is an array.\r\n * @property {Function} classType - The type of the property if it is a class.\r\n * @property {string} jsonProperty - The name of the property in the JSON.\r\n * @property {boolean} nested - Whether the property is a nested object.\r\n * @property {Array<new() => any> | JsonType | JsonType[] | (new() => any)} type - The type of the property.\r\n */\r\nexport type IJsonPropertyMetadata = {\r\n    array: boolean,\r\n    classType?: new() => any,\r\n    jsonProperty: string,\r\n    nested: boolean,\r\n    nullabilityMode?: PropertyNullability,\r\n    type?: DeserializeType,\r\n};\r\n\r\n/**\r\n * Interface for defining options for JSON class.\r\n * @property {PropertyNullability} defaultNullabilityMode - The default nullability mode for properties.\r\n * @property {boolean} mapClassProperties - Whether to try and map JSON properties to class names by default.\r\n * This means you don't need to use @JsonProperty if the property name is the same as the class name.\r\n */\r\nexport type IJsonClassOptions = {\r\n    defaultNullabilityMode?: PropertyNullability,\r\n    mapClassProperties?: boolean,\r\n    passUnknownProperties?: boolean,\r\n};\r\n\r\n/**\r\n * The metadata for a JSON class.\r\n * This is used to store the properties and mixins of a class.\r\n * @property {Array<new() => any>} mixins - The mixins of the class.\r\n * @property {Map<string, IJsonPropertyMetadata>} properties - The properties of the class.\r\n */\r\nexport type IJsonClassMetadata = {\r\n    mixins?: Array<new() => any>,\r\n    options?: IJsonClassOptions,\r\n    properties?: Map<string, IJsonPropertyMetadata>,\r\n};\r\n\r\n/**\r\n * The nullability mode of a property.\r\n * @enum {number}\r\n * @property {number} MAP - Attempt to map null values.\r\n * @property {number} IGNORE - Ignore null values.\r\n * @property {number} PASS - Pass null values.\r\n */\r\nexport enum PropertyNullability {\r\n    MAP = 0,\r\n    IGNORE = 1,\r\n    PASS = 2\r\n}\r\n\r\n/**\r\n * The type of property that should be serialized. This is for JSON primitives.\r\n * @enum {string}\r\n * @property {string} STRING - A string.\r\n * @property {string} NUMBER - A number.\r\n * @property {string} BOOLEAN - A boolean.\r\n * @property {string} OBJECT - An object.\r\n * @property {string} ANY - Any type.\r\n */\r\nexport enum JsonType {\r\n    ANY = 'any',\r\n    BOOLEAN = 'boolean',\r\n    NUMBER = 'number',\r\n    OBJECT = 'object',\r\n    STRING = 'string'\r\n}\r\n\r\n// We export these as constants if users want to import them directly.\r\n\r\n// A JSON string.\r\nexport const STRING = JsonType.STRING;\r\n// A JSON number.\r\nexport const NUMBER = JsonType.NUMBER;\r\n// A JSON boolean.\r\nexport const BOOLEAN = JsonType.BOOLEAN;\r\n// A JSON object.\r\nexport const OBJECT = JsonType.OBJECT;\r\n// Any JSON type.\r\nexport const ANY = JsonType.ANY;\r\n","import {\r\n    GetOrCreateClassMetaData,\r\n} from './helpers';\r\nimport {\r\n    type DeserializeOptions,\r\n    type DeserializeType,\r\n    type IJsonClassMetadata,\r\n    type IJsonPropertyMetadata,\r\n    JsonType,\r\n    PropertyNullability,\r\n    type SerializeOptions,\r\n} from './types';\r\n\r\n/**\r\n * Verifies that the JSON object has all the required properties.\r\n * @param {string} propertyKey The property key.\r\n * @param {IJsonPropertyMetadata} properties The property metadata.\r\n * @param {object} json The JSON object.\r\n * @returns {void}\r\n * @throws {ReferenceError} If the property is not defined in the JSON.\r\n * @throws {TypeError} If the property is null and nullability mode is MAP.\r\n */\r\nconst verifyNullability = (propertyKey: string, properties: IJsonPropertyMetadata, json: object): void => {\r\n    const {\r\n        nullabilityMode,\r\n        jsonProperty,\r\n    } = properties;\r\n\r\n    if (nullabilityMode === PropertyNullability.IGNORE && (json[jsonProperty] === null || json[jsonProperty] === undefined)) {\r\n        return;\r\n    }\r\n\r\n    if (nullabilityMode === PropertyNullability.PASS && (json[jsonProperty] === null || json[jsonProperty] === undefined)) {\r\n        return;\r\n    }\r\n\r\n    if (nullabilityMode === PropertyNullability.MAP && json[jsonProperty] === null) {\r\n        throw new TypeError(`Property ${jsonProperty} is not a ${properties.type}. It is null.`);\r\n    }\r\n\r\n    if (!json.hasOwnProperty(jsonProperty)) {\r\n        throw new ReferenceError(`Property ${jsonProperty} is not defined in the JSON.\\r\\n${JSON.stringify(json, null, 4)}`);\r\n    }\r\n};\r\n\r\n/**\r\n * Verifies that the type of the property is correct.\r\n * @param {string} propertyKey The property key.\r\n * @param {IJsonPropertyMetadata} properties The property metadata.\r\n * @param {object} json The JSON object.\r\n * @param {string} inferredType The inferred type from the default property value.\r\n * @returns {void}\r\n * @throws {TypeError} If the type is incorrect or the property is an array of multiple types.\r\n */\r\nconst verifyType = (propertyKey: string, properties: IJsonPropertyMetadata, json: object, inferredType?: string): void => {\r\n    const {\r\n        jsonProperty,\r\n        nullabilityMode,\r\n    } = properties;\r\n\r\n    let type = properties.type;\r\n\r\n    if (type === undefined && inferredType === undefined) {\r\n        throw new TypeError(`Property ${propertyKey} does not have a type and cannot be inferred from the default value.`);\r\n    }\r\n\r\n    if (type === JsonType.ANY && inferredType === undefined) {\r\n        return;\r\n    }\r\n\r\n    if (inferredType !== undefined && type === undefined) {\r\n        type = inferredType as DeserializeType;\r\n    }\r\n\r\n    if ((typeof json[jsonProperty] === 'undefined' || json[jsonProperty] === null) && nullabilityMode === (PropertyNullability.IGNORE || PropertyNullability.PASS)) {\r\n        return;\r\n    }\r\n\r\n    if (Array.isArray(type)) {\r\n        if (!Array.isArray(json[jsonProperty])) {\r\n            throw new TypeError(`Property ${jsonProperty} is not an array. It is a ${typeof json[jsonProperty]}.`);\r\n        }\r\n\r\n        if (type.length !== 1) {\r\n            throw new TypeError(`Property ${jsonProperty} is an array of multiple types. This is not supported.`);\r\n        }\r\n\r\n        const arrayType = type[0];\r\n        if (arrayType === JsonType.ANY) {\r\n            return;\r\n        }\r\n\r\n        for (const item of json[jsonProperty]) {\r\n            if (typeof item !== arrayType && typeof arrayType !== 'function' || typeof arrayType === 'function' && typeof item !== 'object') {\r\n                throw new TypeError(`Property ${jsonProperty} is not an array of ${arrayType}. It is an array of ${typeof item}.`);\r\n            }\r\n        }\r\n\r\n        return;\r\n    }\r\n\r\n    if (typeof type === 'function' && Object.getPrototypeOf(type.prototype).constructor.name === 'JsonConverter') {\r\n        if (typeof type.prototype.Deserialize !== 'function' || typeof type.prototype.Serialize !== 'function') {\r\n            throw new TypeError(`Property ${propertyKey} is a JsonConverter without a Serialize and/or Deserialize method.`);\r\n        }\r\n\r\n        return;\r\n    }\r\n\r\n    if (typeof type === 'function' && typeof json[jsonProperty] !== 'object') {\r\n        throw new TypeError(`Property ${jsonProperty} is not an object. It is a ${typeof json[jsonProperty]}.`);\r\n    } else if (typeof type === 'function' && typeof json[jsonProperty] === 'object') {\r\n        return;\r\n    }\r\n\r\n    if (type !== typeof json[jsonProperty] && type !== JsonType.ANY) {\r\n        throw new TypeError(`Property ${jsonProperty} is not a ${type}${inferredType ? ' (inferred)' : ''}. It is a ${typeof json[jsonProperty]}.`);\r\n    }\r\n};\r\n\r\n/**\r\n * Maps a property from one object to another. This is used for serialization and deserialization.\r\n * @param {string} propertyKey The property key.\r\n * @param {IJsonPropertyMetadata} properties The property metadata.\r\n * @param {any} fromObject The object to map from.\r\n * @param {any} toObject The object to map to.\r\n * @param {boolean} serialize Whether to serialize or deserialize.\r\n * @param {DeserializeOptions | SerializeOptions} options The options for deserialization or serialization.\r\n * @returns {void}\r\n */\r\nconst mapObjectProperty = (propertyKey: string, properties: IJsonPropertyMetadata, fromObject: any, toObject: any, serialize: boolean = false, options?: DeserializeOptions | SerializeOptions): void => {\r\n    const {\r\n        jsonProperty,\r\n        array,\r\n        nested,\r\n        classType,\r\n        type,\r\n        nullabilityMode,\r\n    } = properties;\r\n\r\n    const fromKey = serialize ? propertyKey : jsonProperty;\r\n    const toKey = serialize ? jsonProperty : propertyKey;\r\n\r\n    if (!serialize) {\r\n        const inferredType = toObject[toKey] === null || toObject[toKey] === undefined ? undefined : typeof toObject[toKey];\r\n        verifyType(propertyKey, properties, fromObject, inferredType);\r\n    }\r\n\r\n    if (typeof type === 'function' && typeof type.prototype.Deserialize === 'function') {\r\n        toObject[toKey] = type.prototype.Deserialize(fromObject[fromKey]);\r\n        return;\r\n    } else if (typeof type === 'function' && typeof type.prototype.Serialize === 'function') {\r\n        fromObject[toKey] = type.prototype.Serialize(fromObject[fromKey]);\r\n        return;\r\n    }\r\n\r\n    if (nested) {\r\n        if (array) {\r\n            toObject[toKey] = fromObject[fromKey].map((item: any) => {\r\n                return serialize ? SerializeObject(item, options) : DeserializeObject(item, classType, options);\r\n            });\r\n        } else {\r\n            toObject[toKey] = serialize ? SerializeObject(fromObject[fromKey], options) : DeserializeObject(fromObject[fromKey], classType, options);\r\n        }\r\n    } else if (array) {\r\n        if (classType === undefined) {\r\n            if (nullabilityMode === PropertyNullability.IGNORE && (fromObject[fromKey] === null || fromObject[fromKey] === undefined)) {\r\n                return;\r\n            }\r\n\r\n            toObject[toKey] = fromObject[fromKey];\r\n            return;\r\n        }\r\n\r\n        toObject[toKey] = fromObject[fromKey].map((item: any) => {\r\n            return serialize ? SerializeObject(item) : DeserializeObject(item, classType);\r\n        });\r\n    } else {\r\n        if (nullabilityMode === PropertyNullability.IGNORE && (fromObject[fromKey] === null || fromObject[fromKey] === undefined)) {\r\n            return;\r\n        }\r\n\r\n        toObject[toKey] = fromObject[fromKey];\r\n    }\r\n};\r\n\r\n/**\r\n * Deserializes a JSON object into an instance of a class.\r\n * @template T\r\n * @param {object | string} json The JSON object to deserialize. Can be a string or an object.\r\n * @param {T} classReference The class reference to deserialize the JSON object into.\r\n * @param {DeserializeOptions} options The options for deserialization.\r\n * @returns {T} The deserialized instance of the class.\r\n * @throws {TypeError} If the JSON object is not an object or string.\r\n * @throws {ReferenceError} If the property is not defined in the JSON.\r\n */\r\nexport const DeserializeObject = <T>(json: object | string, classReference: new() => T, options?: DeserializeOptions): T => {\r\n    const jsonObject: object = typeof json === 'string' ? JSON.parse(json) : json;\r\n\r\n    if (typeof jsonObject !== 'object') {\r\n        throw new TypeError('json is not an object or string.');\r\n    }\r\n\r\n    const instance = new classReference();\r\n\r\n    let classConstructor = classReference;\r\n\r\n    while (classConstructor !== null && classConstructor?.prototype !== Object.prototype) {\r\n        const classMetadata: IJsonClassMetadata = GetOrCreateClassMetaData(classConstructor);\r\n\r\n        for (const mixin of classMetadata.mixins) {\r\n            const mixinObject = DeserializeObject(jsonObject, mixin, options);\r\n            Object.assign(instance, mixinObject);\r\n\r\n            const mixinKeys = Object.getOwnPropertyNames(mixin.prototype);\r\n            for (const mixinKey of mixinKeys) {\r\n                const descriptor = Object.getOwnPropertyDescriptor(mixin.prototype, mixinKey);\r\n                if (descriptor !== undefined && mixinKey !== 'constructor') {\r\n                    Object.defineProperty(instance, mixinKey, descriptor);\r\n                }\r\n            }\r\n        }\r\n\r\n        const propertyKeys = Object.keys(classMetadata?.properties);\r\n\r\n        for (const propertyKey of propertyKeys) {\r\n            classMetadata.properties[propertyKey].nullabilityMode ??= classMetadata.options?.defaultNullabilityMode ?? PropertyNullability.MAP;\r\n            verifyNullability(propertyKey, classMetadata.properties[propertyKey], jsonObject);\r\n            mapObjectProperty(propertyKey, classMetadata.properties[propertyKey], jsonObject, instance, false, options);\r\n        }\r\n\r\n        if (classConstructor?.prototype !== undefined) {\r\n            if (classMetadata.options?.mapClassProperties || options?.mapClassProperties) {\r\n                const classProperties = Object.keys(instance);\r\n\r\n                for (const classProperty of classProperties) {\r\n                    if (!propertyKeys.includes(classProperty)) {\r\n                        const propertyMetadata: IJsonPropertyMetadata = {\r\n                            array: Array.isArray(instance[classProperty]),\r\n                            jsonProperty: classProperty,\r\n                            nested: false,\r\n                            nullabilityMode: classMetadata.options?.defaultNullabilityMode ?? PropertyNullability.MAP,\r\n                            type: JsonType.ANY,\r\n                        };\r\n\r\n                        verifyNullability(classProperty, propertyMetadata, jsonObject);\r\n                        mapObjectProperty(classProperty, propertyMetadata, jsonObject, instance, false, options);\r\n                    }\r\n                }\r\n            }\r\n\r\n            if (classMetadata.options?.passUnknownProperties || options?.passUnknownProperties) {\r\n                const unknownProperties = Object.keys(jsonObject).filter((key) => {\r\n                    return !Object.values(classMetadata.properties).some((property) => {\r\n                        return property.jsonProperty === key;\r\n                    });\r\n                });\r\n\r\n                for (const unknownProperty of unknownProperties) {\r\n                    instance[unknownProperty] = jsonObject[unknownProperty];\r\n                }\r\n            }\r\n        }\r\n\r\n        classConstructor = Object.getPrototypeOf(classConstructor);\r\n    }\r\n\r\n    return instance;\r\n};\r\n\r\n/**\r\n * Serializes an instance of a class into a JSON object.\r\n * @template T\r\n * @param {T} instance The instance of the class to serialize.\r\n * @param {SerializeOptions} options The options for serialization.\r\n * @returns {object} The serialized JSON object.\r\n */\r\nexport const SerializeObject = <T>(instance: T, options?: SerializeOptions): object => {\r\n    const json: object = {};\r\n\r\n    let classConstructor = instance.constructor;\r\n\r\n    while (classConstructor !== null && classConstructor?.prototype !== Object.prototype) {\r\n        const classMetadata: IJsonClassMetadata = GetOrCreateClassMetaData(classConstructor);\r\n\r\n        const propertyKeys = Object.keys(classMetadata?.properties);\r\n\r\n        for (const propertyKey of propertyKeys) {\r\n            mapObjectProperty(propertyKey, classMetadata.properties[propertyKey], instance, json, true, options);\r\n        }\r\n\r\n        if (options?.passUnknownProperties && classConstructor === instance.constructor) {\r\n            const unknownProperties = Object.keys(instance).filter((key) => {\r\n                return !propertyKeys.includes(key);\r\n            });\r\n\r\n            for (const unknownProperty of unknownProperties) {\r\n                json[unknownProperty] = instance[unknownProperty];\r\n            }\r\n        }\r\n\r\n        classConstructor = Object.getPrototypeOf(classConstructor);\r\n    }\r\n\r\n    return json;\r\n};\r\n"],"names":["JsonConverter","MetadataKey","GetOrCreateClassMetaData","constructor","isBuiltInType","type","JsonProperty","jsonProperty","nullabilityMode","target","propertyKey","isArray","isClass","classType","processedType","_a","_b","metadata","targetConstructor","classMetadata","JsonMixin","classes","JsonOptions","options","PropertyNullability","JsonType","STRING","NUMBER","BOOLEAN","OBJECT","ANY","verifyNullability","properties","json","verifyType","inferredType","arrayType","item","mapObjectProperty","fromObject","toObject","serialize","array","nested","fromKey","toKey","SerializeObject","DeserializeObject","classReference","jsonObject","instance","classConstructor","mixin","mixinObject","mixinKeys","mixinKey","descriptor","propertyKeys","_c","classProperties","classProperty","propertyMetadata","_d","_e","unknownProperties","key","property","unknownProperty"],"mappings":"mOA4BO,MAAeA,CAAiB,CAcvC,CCnCa,MAAAC,EAAc,OAAO,qBAAqB,EAO1CC,EAA4BC,GAC9BA,EAAY,eAAeF,CAAW,EAAIE,EAAYF,CAAW,SAAW,OAAO,CACtF,OAAQ,CAAC,EACT,QAAS,CAAC,EACV,WAAmB,OAAA,OAAO,IAAI,CAAA,CACjC,EAQQG,EAAiBC,GACnBA,IAAS,QAAUA,IAAS,QAAUA,IAAS,QCM7CC,EAAe,CAACC,EAAsBF,EAAwBG,IAChE,SAAUC,EAAaC,EAAqB,SACzC,MAAAC,EAAU,MAAM,QAAQN,CAAI,EAClC,IAAIO,EAAU,GACVC,EACAC,EAAgBT,EAEhBD,EAAcC,CAAI,GAAKM,GAAWP,EAAcC,EAAK,CAAC,CAAC,EACvCS,EAAAH,EACZ,EAAEI,EAAAV,EAAK,CAAC,EAA6B,OAAnC,YAAAU,EAAyC,aAAa,GACvDC,EAAAX,EAAgC,OAAhC,YAAAW,EAAsC,eAE3CJ,EAAUD,EAAU,OAAON,EAAK,CAAC,GAAM,WAAa,OAAOA,GAAS,WACpEQ,EAAaD,EAAWD,EAAUN,EAAK,CAAC,EAAIA,EAAQ,QAGxD,MAAMY,EAAkC,CACpC,MAAON,EACP,UAAAE,EACA,aAAAN,EACA,OAAQK,EACR,gBAAAJ,EACA,KAAMM,CAAA,EAGJI,EAAoBT,EAAO,YAC3BU,EAAoCjB,EAAyBgB,CAAiB,EACtEC,EAAA,WAAWT,CAAW,EAAIO,EACxCC,EAAkBj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