I have some data classes that contain lots of `Dou...
# serialization
c
I have some data classes that contain lots of
DoubleArray
instances. Is there a simple way to reduce the precision when serialising them to json? (I'm sending the data to a web client and need to reduce the amount of data being sent, I don't care that I lose some precision in that situation). Seems like I have to completely reimplement both
DoubleArraySerializer
and
DoubleSerializer
, since a lot of the existing implementation is internal and/or can't be subclassed?
d
I’m not at my computer, so I can’t point to the documentation, but you can delegate parts of your implementation to other serializers. That might help reduce the amount of work you need to do.
c
Thanks, yes I can do things like this which helps:
Copy code
override fun deserialize(decoder: Decoder): DoubleArray = DoubleArraySerializer().deserialize(decoder)
Still seems like I end up with a lot of boilerplate but if that's the only way then so it goes