json: fix encode/decode of fixed arrays (fix #22369) (#22448)

This commit is contained in:
Felipe Pena 2024-10-08 13:31:34 -03:00 committed by GitHub
parent e14bc6077b
commit ef72f97b96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 1 deletions

View file

@ -0,0 +1,25 @@
import json
struct Base {
options Options
profiles Profiles
}
struct Options {
cfg [6]u8
}
struct Profiles {
cfg [4][7]u8
}
fn test_main() {
a := json.encode(Base{})
println(a)
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]]')
b := json.decode(Base, a)!
assert b.options.cfg.len == 6
assert b.profiles.cfg.len == 4
assert b.profiles.cfg[0].len == 7
}