From 332d5fa7a825e18c7c4bb908f7ebf01d3eb1251a Mon Sep 17 00:00:00 2001 From: Shakil Siraj Date: Tue, 7 Jan 2025 17:40:44 +1100 Subject: [PATCH] updated type definition --- dist/ObjectMapper.d.ts | 78 ++++++++++++++++++++++++------------------ package.json | 2 +- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/dist/ObjectMapper.d.ts b/dist/ObjectMapper.d.ts index 5610ba8..10d7fd6 100644 --- a/dist/ObjectMapper.d.ts +++ b/dist/ObjectMapper.d.ts @@ -1,40 +1,43 @@ - /** * Decorator metadata definition for JsonProperty */ export interface JsonPropertyDecoratorMetadata { - name?: string, //name of the JSON property to map - required?: boolean, //is this field required in the JSON object that is being deserialized - access?: AccessType, //is this serializable and de-serializable - type?: any //the type of Object that should be assigned to this property - serializer?: any, //Serializer for the type - deserializer?: any // deserializer for the type + name?: string; //name of the JSON property to map + required?: boolean; //is this field required in the JSON object that is being deserialized + access?: AccessType; //is this serializable and de-serializable + type?: any; //the type of Object that should be assigned to this property + serializer?: any; //Serializer for the type + deserializer?: any; // deserializer for the type } export enum AccessType { - READ_ONLY, WRITE_ONLY, BOTH + READ_ONLY, + WRITE_ONLY, + BOTH, } -export interface Serializer{ - serialize(value: any): any; +export interface Serializer { + serialize(value: any): any; } -export interface Deserializer{ - deserialize(value: any): any; +export interface Deserializer { + deserialize(value: any): any; } /** * JsonProperty Decorator function. */ -export declare function JsonProperty(metadata?: JsonPropertyDecoratorMetadata): any; +export declare function JsonProperty( + metadata?: JsonPropertyDecoratorMetadata +): any; /** * Decorator for specifying cache key. * Used for Serializer/Deserializer caching. - * + * * @export - * @param {string} key - * @returns + * @param {string} key + * @returns */ export function CacheKey(key: string): Function; @@ -48,32 +51,41 @@ export declare function JsonIgnore(): any; */ export declare function JsonConverstionError(message: string, json: any): Error; -export declare namespace ObjectMapper { +export interface DeserializationConfig { + ignoreNameMetadata: boolean; +} - /** - * Deserializes a Object type with the passed on JSON data. - */ - export function deserialize(type: { new (): T }, json: Object): T; +export declare namespace ObjectMapper { + /** + * Deserializes a Object type with the passed on JSON data. + */ + export function deserialize( + type: { new (): T }, + json: Object, + config?: DeserializationConfig + ): T; - /** - * Deserializes an array of object types with the passed on JSON data. - */ - export function deserializeArray(type: { new (): T }, json: Object): T[]; + /** + * Deserializes an array of object types with the passed on JSON data. + */ + export function deserializeArray( + type: { new (): T }, + json: Object, + config?: DeserializationConfig + ): T[]; - /** - * Serializes an object instance to JSON string. - */ - export function serialize(obj: any): String; - + /** + * Serializes an object instance to JSON string. + */ + export function serialize(obj: any): String; } /** * Default Date serializer implementation. - * + * * @class DateSerializer * @implements {Serializer} */ export declare class DateSerializer implements Serializer { - public serialize(value: Date): number; + public serialize(value: Date): number; } - diff --git a/package.json b/package.json index 45c0951..c3d6e52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "json-object-mapper", - "version": "1.8.0", + "version": "1.8.1", "description": "A TypeScript library to serialize and deserialize JSON objects in a fast and non-recursive way", "repository": { "type": "git",