Skip to content

Conversation

@afshin-hoseini
Copy link

First of all thank you for this awesome library.

I have added following feature and would be glad if you accept:

  1. Implemented reviver and replacer functions for JsonMemberOptions:

Sometimes it's needed to let a member to revive or replace its own value on serialization and/or deserialization process. As like as currency or metric values which should convert their value.

Definition

/** Will be invoked, with the deserialized value in order to let the member, revive it. */
reviver? : (deserializedValue : any)=>any
/** Will be invoked, with the serialized value in order to let the member, replace it. */
replacer? : (serializedValue : any)=>any

Usage

@JsonMember({
      type : Number, 
      reviver : value=> value + 5, 
      replacer : value=> value * 10 
})
level : number

 - Implemented reviver and replacer functions for JsonMemberOptions
@Jimmy-Hernandez
Copy link

OMG this would be awesome

@Neos3452
Copy link
Collaborator

Neos3452 commented Mar 5, 2019

You can use serializer and deserializer options in the latest version. Or, is it maybe something different?

@afshin-hoseini
Copy link
Author

@Neos3452
Actually it is an old PR, when serializer and deserializer weren't available. 🙂

@Jimmy-Hernandez 🥺You're the only one who told me something like this in my whole life... I'll appreciate it 😀

@Neos3452
Copy link
Collaborator

Neos3452 commented Mar 6, 2019

@afshin-hoseini I know, but if it is different and serves a purpose to someone I would consider rebasing your change. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants