mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
json: omitempty
This commit is contained in:
@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user