mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
json: skip via the "-" attribute
This commit is contained in:
@ -60,6 +60,7 @@ mut:
|
||||
total_comments int
|
||||
file_name string [skip]
|
||||
comments []Comment [skip]
|
||||
skip_field string [json: '-']
|
||||
}
|
||||
|
||||
fn test_skip_fields_should_be_initialised_by_json_decode() {
|
||||
@ -70,6 +71,15 @@ fn test_skip_fields_should_be_initialised_by_json_decode() {
|
||||
assert task.comments == []
|
||||
}
|
||||
|
||||
fn test_skip_should_be_ignored() {
|
||||
data := '{"total_comments": 55, "id": 123, "skip_field": "foo"}'
|
||||
mut task := json.decode(Task, data)!
|
||||
assert task.id == 123
|
||||
assert task.total_comments == 55
|
||||
assert task.comments == []
|
||||
assert task.skip_field == ''
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
struct DbConfig {
|
||||
|
Reference in New Issue
Block a user