We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi there...great library! I usually use automapper-ts, but this is more lightweight and easier to configure.
automapper-ts
It would be cool if the @JsonProperty decorator could accept custom mapping functions.
@JsonProperty
For example:
const deserializeDate = dateString => moment(dateString).toDate(); // pretend this is valid momentjs syntax const convertToStatusEnum = statusString => return enum[statusString] // fetches the appropriate enumerator class Homework { @JsonProperty({name: 'date', mappingFn: deserializeDate }) public dueDate: Date = null; @JsonProperty({mappingFn: convertToStatusEnum}) public status: Statuses = Statuses.NotDone; }
The text was updated successfully, but these errors were encountered:
customConverter should help You
Sorry, something went wrong.
Hey
Do you have an example of how to use customConverter ?
Thanks, Hanan
export const dateConverter: ICustomConverter = { fromJson(data: any): any { return new Date(data); }, toJson(data: Date): any { return data.toJSON(); } }
No branches or pull requests
Hi there...great library! I usually use
automapper-ts
, but this is more lightweight and easier to configure.It would be cool if the
@JsonProperty
decorator could accept custom mapping functions.For example:
The text was updated successfully, but these errors were encountered: