jsoniter-scala icon indicating copy to clipboard operation
jsoniter-scala copied to clipboard

Custom deserialization for single ADT field

Open frankgrimes97 opened this issue 5 years ago • 1 comments

I was thinking that something along the lines of Jackson's @JsonDeserialize annotation would be ideal. Or any way to wire up that configuration without needing to hand-write custom deserialization code for the entire ADT just to override the behaviour for one field. I haven't found any such examples in the codebase or tests and was wondering if this was possible with jsoniter-scala. Thanks!

frankgrimes97 avatar Jan 02 '20 14:01 frankgrimes97

Currently there are no ability to bind a custom codec for the class field. As W/A you can use some custom type for the field (which extends AnyVal as example) or fix parsed by one of transformation libraries like Chimney.

@frankgrimes97 Could you please share your samples of JSON values and a type? Possible some other ideas for enchantment will be suitable for your case.

plokhotnyuk avatar Jan 02 '20 15:01 plokhotnyuk