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

stipple_parse structs #279

Merged
merged 3 commits into from
May 3, 2024
Merged

stipple_parse structs #279

merged 3 commits into from
May 3, 2024

Conversation

hhaensel
Copy link
Member

@hhaensel hhaensel commented May 2, 2024

Add automatic struct parsing for both normal structs and structs defined by @kwdef:

struct HH1
  c::Int
  d::Int
end

struct HH2
  a::Int
  b::HH1
end

hh2 = HH2(1, HH1(2, 3))
hh2_dict = JSON3.read(json(hh2), Dict)

Base.@kwdef struct T1
  c::Int = 1
  d::Int = 3
end

Base.@kwdef struct T2
  a::Int = 1
  b::T1 = T1()
end

Stipple.stipple_parse(HH2, hh2_dict)
# HH2(1, HH1(2, 3))

Stipple.stipple_parse(T1, Dict())
# T1(1, 3)

Stipple.stipple_parse(T2, Dict())
# T2(1, T1(1, 3))

@hhaensel hhaensel merged commit a9151d9 into master May 3, 2024
20 checks passed
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

Successfully merging this pull request may close these issues.

None yet

1 participant