1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

json: omitempty

This commit is contained in:
Alexander Medvednikov
2021-09-16 07:02:43 +03:00
parent 5bc6cc9512
commit d00808660f
2 changed files with 22 additions and 0 deletions

View File

@ -366,3 +366,17 @@ fn test_pretty() {
"name": "Bob"
}'
}
struct Foo3 {
name string
age int [omitempty]
}
fn test_omit_empty() {
foo := Foo3{'Bob', 0}
assert json.encode_pretty(foo) == '{
"name": "Bob"
}'
// println('omitempty:')
// println(json.encode_pretty(foo))
}