v2 / vlib / json / tests / json_fixed_array_test.v
25 lines · 20 sloc · 411 bytes · 8ebbacecd60366ac4ba68aa35f9b0e7a0e56ff61
Raw
1import json
2
3struct Base {
4 options Options
5 profiles Profiles
6}
7
8struct Options {
9 cfg [6]u8
10}
11
12struct Profiles {
13 cfg [4][7]u8
14}
15
16fn test_main() {
17 a := json.encode(Base{})
18 println(a)
19 assert a.contains('"cfg":[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]]')
20
21 b := json.decode(Base, a)!
22 assert b.options.cfg.len == 6
23 assert b.profiles.cfg.len == 4
24 assert b.profiles.cfg[0].len == 7
25}
26