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

29 lines
426 B
V

import json
struct User {
name string
}
struct MyStruct {
user &User //
users map[string]User
users2 map[string]&User
}
fn test_json_encode_with_ptr() {
user := User{
name: 'foo'
}
data := MyStruct{
user: &user
users: {
'keyfoo': user
}
users2: {
'keyfoo': &user
}
}
assert json.encode(data) == '{"user":{"name":"foo"},"users":{"keyfoo":{"name":"foo"}},"users2":{"keyfoo":{"name":"foo"}}}'
}