Skip to content
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

Compile-time safety for custom adapters? #29

Closed
fab1an opened this issue Oct 18, 2017 · 2 comments
Closed

Compile-time safety for custom adapters? #29

fab1an opened this issue Oct 18, 2017 · 2 comments
Labels

Comments

@fab1an
Copy link

fab1an commented Oct 18, 2017

Is there any way to get compile-time safety with this library?

This was one of the reasons I wrote my own serialization library: https://medium.com/@spitzwegerich/generated-json-serialisation-for-kotlin-4470dabe40b8.

A main advantage is that I can be sure at compile-time that every (custom) type in every object has a proper adapter registered.

@sandwwraith
Copy link
Member

Because every serializer on classes marked as @Serializable is resolved statically in compile-time by plugin, this library is type-safe. You also can use explicit form of stringify(T, KSerializer<T>) if you prefer, for example, for lists (see #27).

One exception for now is user-registered external serializers. Because they are unknown at the time of compiling class itself, or there can be more than one serializer for specified class, their resolving is postponed until runtime (that's why you need to explicitly register them).

@sandwwraith
Copy link
Member

Information about custom serializers updated in latest doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants