mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
24 lines
366 B
V
24 lines
366 B
V
import json
|
|
|
|
pub struct SomeStruct {
|
|
pub mut:
|
|
test ?string
|
|
}
|
|
|
|
pub struct MyStruct {
|
|
pub mut:
|
|
result ?SomeStruct
|
|
id string
|
|
}
|
|
|
|
fn test_main() {
|
|
a := MyStruct{
|
|
id: 'some id'
|
|
result: SomeStruct{}
|
|
}
|
|
encoded_string := json.encode(a)
|
|
assert encoded_string == '{"result":{},"id":"some id"}'
|
|
test := json.decode(MyStruct, encoded_string)!
|
|
assert test == a
|
|
}
|