Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vdayanand opened this issue Sep 24, 2024 · 0 comments

Comments

@vdayanand
Copy link

vdayanand commented Sep 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant