Description
JSON.jl allows for customizing how instances of a Julia type are serialized to JSON by defining a show_json
method on a custom subtype of CommonSerialization
.
There doesn't seem to be a way to specialize parse
to reconstruct an analog of the original object from that serialization though.
For example, Regex isn't serializable using CommonSerialization
because it contains a Ptr
. A custom serialization could represent the Regex as a combination of a tag and a string. I don't see a way to customize parse
to make a Regex from that string when it recognizes that tag. One would need to walk the entire data structure looking for and replacing these custom serializations.
This would only work when the JSON is being parsed using the same custom Serialization
, but that is better than nothing.
Python supports thus functionality by passing 'hook' functions to load
and loads
.