Skip to content

Support UnorderedStruct #19

@chris-b1

Description

@chris-b1

xref quinnj/JSON3.jl#113 & JuliaData/StructTypes.jl#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)

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