You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For simple converters, creating an IPropertyConverter seems a bit overkill. It would be nice to specify a function as part of a decorator for serialization or deserialization.
For example:
@JsonProperty('wifi_signal')
@JsonDeserailizer((value)=>!value ? 0 : value*20)public wifiSignalStrength: number
@JsonProperty('wifi_signal')
@JsonSerializer((value)=>!value ? 0 : value/20)public wifiSignalStrength: number
Thoughts?
Cheers,
Joe
The text was updated successfully, but these errors were encountered:
I do really like the idea actually - though I feel it would be cleaner to have it as a single decorator, as I worry 2 is a bit verbose at times.
My first thought would be something like @JsonDeserializer(v => ..., v => ...) - however this doesn't catch the case where you may only want one, in a readonly or writeonly property perhaps.
Instead, what about something like passing an object, { serializer: v => ..., deserializer: v => ... }, where each one is optional? Though again, heading into the realm of needless verbosity...
I also thought about a single decorator with a serializer and/or deserializer object property, but figured since one was going to type the word serializer and/or deserializer, then it might make more sense to split them into different decorators.
I brought it up because for my scenario, I was creating a DTO where my deserialization is different than the serialization. That's where it would be nice to provide individual decorators for serialize and deserialize.
For simple converters, creating an
IPropertyConverter
seems a bit overkill. It would be nice to specify a function as part of a decorator for serialization or deserialization.For example:
Thoughts?
Cheers,
The text was updated successfully, but these errors were encountered: