mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
json: allow passing an anon struct as a decode type (#22228)
This commit is contained in:
parent
0c8ce3bcb9
commit
97c9f5f9e4
6 changed files with 36 additions and 7 deletions
9
vlib/json/json_decode_anon_struct_test.v
Normal file
9
vlib/json/json_decode_anon_struct_test.v
Normal file
|
@ -0,0 +1,9 @@
|
|||
import json
|
||||
|
||||
fn test_main() {
|
||||
json_text := '{ "a": "b" }'
|
||||
b := json.decode(struct {
|
||||
a string
|
||||
}, json_text)!.a
|
||||
assert dump(b) == 'b'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue