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

json2: encode reference fields too (#17058)

This commit is contained in:
Hitalo Souza
2023-04-28 10:24:27 -03:00
committed by GitHub
parent 433208ea7e
commit b0589c645d
6 changed files with 63 additions and 43 deletions

View File

@@ -265,6 +265,25 @@ fn test_encode_alias_field() {
assert s == '{"sub":{"a":1}}'
}
struct APrice {}
pub struct Association {
association &Association = unsafe { nil }
price APrice
}
//! FIX: returning null
fn test_encoding_struct_with_pointers() {
value := Association{
association: &Association{
price: APrice{}
}
price: APrice{}
}
// println(value)
assert json.encode(value) == '{"association":{"price":{}},"price":{}}'
}
pub struct City {
mut:
name string

View File

@@ -367,21 +367,3 @@ fn test_encode_sumtype_defined_ahead() {
ret := create_game_packet(&GamePacketData(GPScale{}))
assert ret == '{"value":0,"_type":"GPScale"}'
}
struct APrice {}
struct Association {
association &Association = unsafe { nil }
price APrice
}
//! FIX: returning null
fn test_encoding_struct_with_pointers() {
value := Association{
association: &Association{
price: APrice{}
}
price: APrice{}
}
assert json.encode(value) == '{"association":{"price":{}},"price":{}}'
}