You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
returnDict(
"debugId"=>...,
)
end
One 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! :^)
The text was updated successfully, but these errors were encountered:
I think your second proposal (the JSON.lower(::CommonSerialization, x::Any) = JSON.lower(x)) is pretty reasonable, and is compatible with the direction we've gone (support for serialization contexts while making it "easy" to use the default one). A PR is certainly welcome!
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 formOne issue with the proposal above is that it would probably require existing definitions of
JSON.lower(x::MyType) = ...
to be re-written asJSON.lower(::CommonSerialization, x::MyType)
. Either that or definewhich wouldn't be breaking (afaict).
If there are better ways to do what I'm describing, I'm all ears! :^)
The text was updated successfully, but these errors were encountered: