mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
json: fix -cstrict build + optional map (#18014)
This commit is contained in:
parent
4c54f36a70
commit
c43ea09d87
2 changed files with 82 additions and 31 deletions
22
vlib/json/json_encode_map_test.v
Normal file
22
vlib/json/json_encode_map_test.v
Normal file
|
@ -0,0 +1,22 @@
|
|||
import json
|
||||
|
||||
struct Test {
|
||||
optional_string ?string
|
||||
optional_array ?[]string
|
||||
optional_struct_array ?[]string
|
||||
optional_map ?map[string]string
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
test := Test{}
|
||||
encoded := json.encode(test)
|
||||
assert dump(encoded) == '{}'
|
||||
|
||||
test2 := Test{
|
||||
optional_map: {
|
||||
'foo': 'bar'
|
||||
}
|
||||
}
|
||||
encoded2 := json.encode(test2)
|
||||
assert dump(encoded2) == '{"optional_map":{"foo":"bar"}}'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue