mirror of
https://github.com/vlang/v.git
synced 2025-09-15 23:42:28 +03:00
json2: encode reference fields too (#17058)
This commit is contained in:
parent
433208ea7e
commit
b0589c645d
6 changed files with 63 additions and 43 deletions
|
@ -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
|
||||
|
|
|
@ -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":{}}'
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue