Skip to content

x.json2.decoder2: fix array decoding in struct is field, when array is initialized#24422

Merged
spytheman merged 2 commits into
vlang:masterfrom
enghitalo:decoder2/fix-initialized-array
May 6, 2025
Merged

x.json2.decoder2: fix array decoding in struct is field, when array is initialized#24422
spytheman merged 2 commits into
vlang:masterfrom
enghitalo:decoder2/fix-initialized-array

Conversation

@enghitalo

@enghitalo enghitalo commented May 5, 2025

Copy link
Copy Markdown
Contributor
import x.json2 as json
import x.json2.decoder2

struct Bar {
	b []int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}

struct Foo {
	Bar
	a []int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}

fn test_main() {
	str := json.encode(Foo{})
	assert decoder2.decode[Foo](str)!.str() == 'Foo{
    Bar: Bar{
        b: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    }
    a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}'
}

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22794

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.

@spytheman spytheman merged commit a412f53 into vlang:master May 6, 2025
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.

2 participants