mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
json: minor fixes + bring back the test
This commit is contained in:
parent
6e1825b417
commit
9823d80e0c
3 changed files with 26 additions and 4 deletions
|
@ -1,5 +1,22 @@
|
|||
import json
|
||||
|
||||
struct Employee {
|
||||
name string
|
||||
age int
|
||||
}
|
||||
|
||||
fn test_simple() {
|
||||
x := Employee{'Peter', 28}
|
||||
s := json.encode(x)
|
||||
assert s == '{"name":"Peter","age":28}'
|
||||
y := json.decode(Employee, s) or {
|
||||
assert false
|
||||
}
|
||||
assert y.name == 'Peter'
|
||||
assert y.age == 28
|
||||
}
|
||||
|
||||
/*
|
||||
struct User {
|
||||
age int
|
||||
nums []int
|
||||
|
@ -43,3 +60,4 @@ fn test_raw_json_field() {
|
|||
assert color.point == '{"Y":123}'
|
||||
assert color.space == 'YCbCr'
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue