mirror of
https://github.com/vlang/v.git
synced 2025-08-04 02:07:28 -04:00
20 lines
519 B
V
20 lines
519 B
V
import json
|
|
|
|
struct PostTag {
|
|
id string
|
|
parent ?&PostTag
|
|
visibility string
|
|
created_at string @[json: 'createdAt']
|
|
metadata string @[raw]
|
|
}
|
|
|
|
fn test_main() {
|
|
new_post_tag := &PostTag{}
|
|
assert json.encode(new_post_tag) == '{"id":"","visibility":"","createdAt":"","metadata":""}'
|
|
|
|
new_post_tag2 := PostTag{
|
|
parent: new_post_tag
|
|
}
|
|
assert json.encode(new_post_tag2) == '{"id":"","parent":{"id":"","visibility":"","createdAt":"","metadata":""},"visibility":"","createdAt":"","metadata":""}'
|
|
}
|