What `descriptor` should I declare for a custom se...
# serialization
c
What
descriptor
should I declare for a custom serializer in a
sealed class
? It reads the field
type
and chooses between the subtype serializers based on it.
e
can you just wrap the generated serializer's descriptor? the functions to create a new polymorphic descriptor are internal afaik
c
I'm not sure. I'm creating GeoJSON classes, and they always have the
type
, even when encoding without polymorphism:
Copy code
{
  "type": "Point",
  "coordinates": [
    0.1,
    2.2
  ]
}
Because there are quite a few weird things here (e.g. the coordinates becoming an array), I wrote a custom serializer for them. However, the default serializer for the sealed class gets confused and tries to generate:
Copy code
{
  "type": "Point",
  "value": {
    "type": "Point",
    "coordinates": [
      0.1,
      2.2
    ]
  }
}
instead of just using the value itself