Unmarshalling to a Julia type when type has Union in the Attribute values?

Defining the function as proposed is doing what you want:

julia> import Unmarshal.unmarshal

julia> unmarshal(::Type{Union{T,Nothing}}, x :: String, verbose :: Bool = false, verboseLvl :: Int = 0) where T = unmarshal(T, x, verbose, verboseLvl)
unmarshal (generic function with 69 methods)

julia> Unmarshal.unmarshal(UserY, JSON.parse(input))
UserY(25073877, "25073877")

But I think that this would be worth opening an issue at… I see, you already did:
https://github.com/lwabeke/Unmarshal.jl/issues/31

Well done.

2 Likes