1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/json/json_alias_test.v

27 lines
438 B
V
Raw Normal View History

import json
pub struct User {
name string
age int
height f64
}
type Users = map[string]User
const json_users = '{
"tom": { "name": "Tom", "age": 45, "height": 1.97 },
"martin": { "name": "Martin", "age": 40, "height": 1.8 }
}'
fn test_alias_with_map() {
a := json.decode(map[string]User, json_users)!
b := json.decode(Users, json_users)!
assert Users(a) == b
c := json.encode(a)
d := json.encode(b)
assert c == d
}