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
Hi, firstly thanks for the package, really cool :)
I've noticed when trying to implement the JSON3 plumbing for parametric types, JSON3.write doesn't include the subtype key in its output if it's not a field name? This means that the round trip of writing and then reading back in some parametric structs won't work as expected (unless in my understanding you make the sub type key a field?) . E.g.
using JSON3
using StructTypes
struct A{T}
x::Tend
StructTypes.StructType(::Type{A}) = StructTypes.AbstractType()
StructTypes.StructType(::Type{A{T}}) where T = StructTypes.Struct()
StructTypes.subtypekey(::Type{A}) =:_type# just define this for one type for this example
StructTypes.subtypes(::Type{A}) =NamedTuple{ (Symbol("A{Float64}"),)}( (A{Float64}))
# errors
a =A{Float64}(1.0)
JSON3.read(JSON3.write(a), A)
Since in our use case we'd like to be able to automatically define this plumbing purely based on the parametric type T, it would be great to automatically include the subtype key in the write code rather than expect it to be a field?
Thanks alot!
The text was updated successfully, but these errors were encountered:
Hi, firstly thanks for the package, really cool :)
I've noticed when trying to implement the JSON3 plumbing for parametric types,
JSON3.write
doesn't include the subtype key in its output if it's not a field name? This means that the round trip of writing and then reading back in some parametric structs won't work as expected (unless in my understanding you make the sub type key a field?) . E.g.Since in our use case we'd like to be able to automatically define this plumbing purely based on the parametric type
T
, it would be great to automatically include the subtype key in the write code rather than expect it to be a field?Thanks alot!
The text was updated successfully, but these errors were encountered: