Hello.
The package JSON.jl
made the interesting design decision to make singleton structs unserializable.
This behavior is implemented in this function in the source code.
function lower(a)
if nfields(a) > 0
CompositeTypeWrapper(a)
else
error("Cannot serialize type $(typeof(a))")
end
end
However, I find this behavior interesting and I was wondering why this was the case. Empty Dicts and named tuples,are handled and return a simple {}
JSON object. Empty tuples and arrays return []
. Shouldn’t singletons return {}
by default?
Thank you!