I get the point of having special de/serializers b...
# serialization
k
I get the point of having special de/serializers but it would be sweet if annotated objects defaulted to just having a static method that handles the serialization. I would mention I'm loving Kotlins serialization. It's great. I'm also amazed at how well Kotlins plugin annotation system works.
e
Can you please elaborate what do you mean by “just having static method that handles the serialization” (take into account that Kotlin does not have static methods)
t
I guess toJsonString() though is it not static. Static would be fromJsonString().
k
Ya sorry for not being clear. First I agree with the design decision to have an object handle the serialization (such as Json, XML, etc). I meant the serialization strategy classes in my post. By that I mean an @Serializable class would default to having a static (or companion object) instance of it's serializer for basic serialization. So I would only need to pass in the object or a string and the class reference for basic serialization.
d
Hmm, how is that different from the current behaviour?
k
The current behavior is you construct the default serialization strategy and pass it on into the serializer
This would make default serializations simpler as well as eliminating having to cache the serialization strategy yourself in performance critical areas
c
k
Not quite. I wouldn't want to be forced to use the static Json object. Also that doesn't resolve the issue of caching the serializer strategies.