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

json: fix encoding of structs with pointers; add test

This commit is contained in:
Delyan Angelov
2022-09-23 14:07:44 +03:00
parent ea8b30fd91
commit a6576bec1d
2 changed files with 32 additions and 4 deletions

View File

@@ -508,3 +508,22 @@ fn test_encode_alias_field() {
println(s)
assert s == '{"sub":{"a":1}}'
}
//
struct APrice {}
struct Association {
association &Association = unsafe { nil }
price APrice
}
fn test_encoding_struct_with_pointers() {
value := Association{
association: &Association{
price: APrice{}
}
price: APrice{}
}
assert json.encode(value) == '{"association":{"price":{}},"price":{}}'
}