mirror of
https://github.com/vlang/v.git
synced 2025-09-16 19:06:24 -04:00
This commit is contained in:
parent
57a45bc353
commit
8201b8a45f
@ -169,6 +169,9 @@ fn (mut f Fmt) write_anon_struct_field_decl(field_typ ast.Type, field_anon_decl
|
||||
elem_sym := f.table.sym(sym.info.elem_type)
|
||||
if elem_sym.info is ast.Struct {
|
||||
if elem_sym.info.is_anon {
|
||||
if field_typ.has_flag(.option) {
|
||||
f.write('?')
|
||||
}
|
||||
f.write('[]'.repeat(sym.info.nr_dims))
|
||||
f.write_anon_struct_field_decl(sym.info.elem_type, field_anon_decl)
|
||||
return true
|
||||
|
22
vlib/v/fmt/tests/array_option_anon_struct_keep.vv
Normal file
22
vlib/v/fmt/tests/array_option_anon_struct_keep.vv
Normal file
@ -0,0 +1,22 @@
|
||||
module main
|
||||
|
||||
import json
|
||||
|
||||
struct Data {
|
||||
mut:
|
||||
a_token ?[]string
|
||||
dfv ?[]struct {
|
||||
key string
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
j := '{
|
||||
"a_token2": ["one", "two"],
|
||||
"a_email2": {
|
||||
"email": "email@email.ru"
|
||||
}
|
||||
}'
|
||||
d := json.decode(Data, j)!
|
||||
println(d)
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user