mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
json: omitempty
This commit is contained in:
parent
5bc6cc9512
commit
d00808660f
2 changed files with 22 additions and 0 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue