json: minor fixes + bring back the test

This commit is contained in:
Alexander Medvednikov 2020-05-04 20:43:22 +02:00
parent 6e1825b417
commit 9823d80e0c
3 changed files with 26 additions and 4 deletions

View file

@ -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'
}
*/