Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated type definition #84

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading