TypedJSON
TypedJSON copied to clipboard
JsonMember's reviver and replacer
First of all thank you for this awesome library.
I have added following feature and would be glad if you accept:
- Implemented
reviver
andreplacer
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
OMG this would be awesome
You can use serializer and deserializer options in the latest version. Or, is it maybe something different?
@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 😀
@afshin-hoseini I know, but if it is different and serves a purpose to someone I would consider rebasing your change. :)