-
Notifications
You must be signed in to change notification settings - Fork 106
Closed
Description
Would it be possible to pass the serialization context to JSON.lower? Typically, the thing I want to override is the shape of the thing that's being lowered rather than the formatting and this would make it much easier.
e.g. I could define a VerboseSerializationContext and just have overloads of the form
function JSON.lower(::VerboseSerializationContext, s::MyStruct)
return Dict(
"debugId" => ...,
)
endOne issue with the proposal above is that it would probably require existing definitions of JSON.lower(x::MyType) = ... to be re-written as JSON.lower(::CommonSerialization, x::MyType). Either that or define
# Let the single-arg form be the "common" form
JSON.lower(::CommonSerialization, x::Any) = JSON.lower(x)which wouldn't be breaking (afaict).
If there are better ways to do what I'm describing, I'm all ears! :^)
Reactions are currently unavailable