Closed hubertp closed 5 months ago
@hubertp Hi, Hubert!
Thanks for trying and sending your feedback!
Generated codecs are always the same for the same jsoniter-scala version, derivation configuration and a way of injection of custom codecs using implicit val
and def
functions.
I've tried to compile polyglot-api
module from your demonstrating PR, but, unfortunately, it has a lot of required prerequisites to be installed...
Do you have any isolated example to see your expectations and results clearly?
From your PR I learned that jsoniter-scala docs should be improved to clearly state that CodecMakerConfig
can be used only in compile time, as an expression parameter of JsonCodecMaker.make
call. If you want to have derivation configuration in one place then need to create a separated module with a macro function that has your pre-configured JsonCodecMaker.make
implementation. So after that you can call your macro instead of JsonCodecMaker.make
everywhere without copying the configuration expression.
Thanks for the info. Moving serde logic to a separate module appears to have solved the problem. Probably a combination of incremental compilation + macros led to this non-determinism.
I'm trying to replace Jackson serialization with jsoniter and encountering some issues with serialization.
The problems appears to be during deserialization of
Option
values in case classes. Macro for writingfoo: Option[String]
field will always generate something similar to(decompiled code, for reference only)
While reading will generate either 1:
or 2:
where
d99
is roughly generated asObviously, given the serialization code, I would expect only option 1, which is generated in the macro. But sometimes it generates deserialization for JSON value in 2 and complains with the usual
where
parentType: Option[String]
. PR demonstrating the issue https://github.com/enso-org/enso/pull/10035 in a target project. Anyone encountered this as well?