StructTypes.jl
StructTypes.jl copied to clipboard
Error while deserializing when type has excluded fields (support excludes for struct)
@kwdef struct Person
name::String
fingers::Int=2
end
StructTypes.excludes(::Type{Human}) = (:fingers,)
In the above example, JSON3.write(Person("John")) returns {"name":"John"} as expected. However when we deserialize, we get Cannot `convert` an object of type Nothing to an object of type Int. Instead of setting fingers to nothing, it should probably call a constructor without fingers so that it sets default value 2?