v / vlib / json / tests / json_decode_struct_default_test.v
20 lines · 17 sloc · 345 bytes · 5eecd04eee3b48c9e2b25f4947acb0120b7956e8
Raw
1import json
2
3struct Bar {
4 b []int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
5}
6
7struct Foo {
8 Bar
9 a []int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
10}
11
12fn test_main() {
13 str := json.encode(Foo{})
14 assert json.decode(Foo, str)!.str() == 'Foo{
15 Bar: Bar{
16 b: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
17 }
18 a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
19}'
20}
21