Pass serializer into aggregate serialization interface methods #56
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Problem
The proposal in #55 got me thinking.
In Getty JSON, the implementation for the aggregate serialization interfaces (e.g.,
getty.ser.Seq
,getty.ser.Map
) has a field referencing the serializer passed toserializeSeq
,serializeStruct
, etc. I believe the field is used in every single one of the aggregate interface methods (no surprise there; most of them are literally calledserializeX
).But having to carry this field around in the implementation isn't ideal. Any SB that calls
serializeSeq
already has a reference to the same serializer, so there's no need to store it in the implementation. Also, it makes more sense to have the serializer as a parameter of the methods doing the serialization than on the impl itself.Proposal
So, what if we pass in the serializer to the methods like
serializeElement
,serializeKey
, and so on? The SB callingserializeStruct
would always have a reference to the relevant serializer so it'd be easy to pass it in for them.This would simplify implementations of the aggregate interfaces since they'd no longer need to keep a redundant serializer around.
Alternatives
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: