Skip to content

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

@vdayanand

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions