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
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.
The text was updated successfully, but these errors were encountered:
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 ofCommonSerialization
.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 aPtr
. A custom serialization could represent the Regex as a combination of a tag and a string. I don't see a way to customizeparse
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
andloads
.The text was updated successfully, but these errors were encountered: