StructTypes.jl icon indicating copy to clipboard operation
StructTypes.jl copied to clipboard

Error while deserializing when type has excluded fields (support excludes for struct)

Open vdayanand opened this issue 1 year ago • 0 comments

@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?

vdayanand avatar Sep 24 '24 08:09 vdayanand