Skip to content

Commit

Permalink
updated type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
shakilsiraj committed Jan 7, 2025
1 parent 9eda9af commit 332d5fa
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 34 deletions.
78 changes: 45 additions & 33 deletions dist/ObjectMapper.d.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<T>(type: { new (): T }, json: Object): T;
export declare namespace ObjectMapper {
/**
* Deserializes a Object type with the passed on JSON data.
*/
export function deserialize<T>(
type: { new (): T },
json: Object,
config?: DeserializationConfig
): T;

/**
* Deserializes an array of object types with the passed on JSON data.
*/
export function deserializeArray<T>(type: { new (): T }, json: Object): T[];
/**
* Deserializes an array of object types with the passed on JSON data.
*/
export function deserializeArray<T>(
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;
}

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 332d5fa

Please sign in to comment.