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

Support UnorderedStruct

Open chris-b1 opened this issue 4 years ago • 0 comments

xref https://github.com/quinnj/JSON3.jl/pull/113 & https://github.com/JuliaData/StructTypes.jl/pull/35/

I think Strapping should follow the behavior of JSON3 with respect to Ordered / Unordered? Simple repro below

import StructTypes
import Strapping

struct Person
    name::String
    id::Int
end
StructTypes.StructType(::Type{Person}) = StructTypes.UnorderedStruct()  # aka StructTypes.Struct()

julia> Strapping.construct(Person, [(; name="Bob", id=1)])
Person("Bob", 1)

julia> Strapping.construct(Person, [(; id=1, name="Bob")])
ERROR: MethodError: no method matching String(::Int64)

chris-b1 avatar Oct 25 '21 19:10 chris-b1