elcolto / GeoKJSON

Multiplatform Library for GeoJSON
https://elcolto.github.io/GeoKJSON/
Apache License 2.0
2 stars 0 forks source link

Check SERIALIZER_TYPE_INCOMPATIBLE suppressed classes #10

Open elcolto opened 5 months ago

elcolto commented 5 months ago

Maybe a polymporph serializer would fit better

JanTie commented 5 months ago

Not as easy as expected. I did not find a way to provide the Serializer for multiple sub-types, so we can't get rid of the warning. I would not recommend to remove the serializeWith or the custon serializers. KotlinxSerialization only serializes the type if the type is generic during compile time. So if you try to serialize

val point: Point = Point(...)
println(Json.encodeToString(point))

the type gets scraped, whereas

val point: Geometry = Point(...)
println(Json.encodeToString(point))

would print the type, as the type expected to be generic here.

Additionally, the custom serializers contain some logic, such as the BoundingBoxSerializer that ensures that the array contains 4/6 entries to ensure a valid 2d/3d coordinate representative

elcolto commented 4 months ago

Maybe we should convert all Serializer to internal visibility