-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating a custom SerialModule
for Json seems useless
#697
Comments
I have a basic idea in mind where the Would you be interested in receiving PRs for that? |
@suushiemaniac Thanks for the offer, but we already have the solution (and had a lot of discussions to come up with it) in mind and are starting to prototype it. Chaining (keeping references and invoking both methods) was one of the first candidates, but The problem is, in fact, that What we intend to do is the following:
It would be really nice if you could elaborate on your particular use-case. Why do you need to override |
Thanks for the quick and detailed reply, @qwwdfsad ! Great explanation on why chaining is a bad idea 👍 Actually, my use case is described and discussed in #448. I have a list of objects where for some of them, I want to "skip" deserializing. I realise that entirely skipping them may be difficult (EDIT: as per #514), so it is a conceivable option to provide a Longer version: There's an API providing a list of objects, that a lot of people have write access to. There is only this one "master" list, and I want to be able to read and write my parts of the cake (ie the ones I have serializers for) without interfering with what other people possibly stored in the API as well. |
* As explained in #697, it appears that concatenating two modules as "behaviours" (as opposed to "bag of serializers") is way too dangerous for the end users and implies a lot of inconsistent behaviours and performance hits. So the most rational solution here is to prohibit such concatenations by closing the way to implement your own SerialModule * In order to still solve "fallback serializer" use-case, new 'default' DSL is introduced along with its support in PolymorphicSerializer Fixes #697 Fixes #448
* As explained in #697, it appears that concatenating two modules as "behaviours" (as opposed to "bag of serializers") is way too dangerous for the end users and implies a lot of inconsistent behaviours and performance hits. So the most rational solution here is to prohibit such concatenations by closing the way to implement your own SerialModule * In order to still solve "fallback serializer" use-case, new 'default' DSL is introduced along with its support in PolymorphicSerializer Fixes #697 Fixes #448
* As explained in #697, it appears that concatenating two modules as "behaviours" (as opposed to "bag of serializers") is way too dangerous for the end users and implies a lot of inconsistent behaviours and performance hits. So the most rational solution here is to prohibit such concatenations by closing the way to implement your own SerialModule * In order to still solve "fallback serializer" use-case, new 'default' DSL is introduced along with its support in PolymorphicSerializer Fixes #697 Fixes #448
* As explained in #697, it appears that concatenating two modules as "behaviours" (as opposed to "bag of serializers") is way too dangerous for the end users and implies a lot of inconsistent behaviours and performance hits. So the most rational solution here is to prohibit such concatenations by closing the way to implement your own SerialModule * In order to still solve "fallback serializer" use-case, new 'default' DSL is introduced along with its support in PolymorphicSerializer Fixes #697 Fixes #448
* As explained in #697, it appears that concatenating two modules as "behaviours" (as opposed to "bag of serializers") is way too dangerous for the end-users and implies a lot of inconsistent behaviours and performance hits. So the most rational solution here is to prohibit such concatenations by closing the way to implement your own SerialModule * In order to still solve "fallback serializer" use-case, new 'default' DSL is introduced along with its support in PolymorphicSerializer Fixes #697 Fixes #448
Describe the bug
When creating my own
SerialModule
implementation to pass along as context, I have to overwrite several methods with names such asgetPolymorphic
-- which to me implies that these methods will be called/invoked at runtime if I use my context and something tries to (de-)serialize polymorphic values.In reality however, this does not happen because the
Json
constructor invokes aplus
operation and the modules are combined viadumpTo
which only supports statically determined seralizer mappings.To Reproduce
Minimal-ish example to show my point:
Expected behavior
I expect the line
do something dynamic depending on something!
to be printed when executing. This does not happen -- in fact, nothing gets printed at all before the finalprintln(parsed)
statement.I've taken a look at the code and it seems that the
dumpTo
method uses aSerialModuleCollector
which is backed by a defaultSerialModuleImpl
. This is unfortunate because it statically collects all pre-registered serialisers into one big map and then allows no dynamic invocation at runtime because it only usesMap#get
.It also defies the intuition that overriding any method other than
dumpTo
in theSerialModule
interface would achieve anything, which makes me wonder why these methods are there in the first place.For more context, please see my description and code sample at #448. I have a
sealed class
hierarchy ofextension
objects that are relevant for me, but I also need to parse "unknown" extensions (that were created by other people) into some form of "fallback extension". That is only possible, however, if I can dynamically intercept the serialiser lookup at runtime.Thanks for your help and your amazing library! :)
Environment
The text was updated successfully, but these errors were encountered: