mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
parent
56e6fd01c5
commit
c9dcdf6744
3 changed files with 38 additions and 4 deletions
21
vlib/json/json_decode_with_optional_arg_test.v
Normal file
21
vlib/json/json_decode_with_optional_arg_test.v
Normal file
|
@ -0,0 +1,21 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
struct DbConfig {
|
||||
foo int
|
||||
}
|
||||
|
||||
fn test_json_decode_with_optional_arg() {
|
||||
if ret := print_info() {
|
||||
println(ret)
|
||||
} else {
|
||||
println(err)
|
||||
}
|
||||
assert true
|
||||
}
|
||||
|
||||
fn print_info() ?string {
|
||||
dbconf := json.decode(DbConfig, os.read_file('dbconf.json') ?) ?
|
||||
println(dbconf)
|
||||
return '$dbconf'
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue