mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Allow json to unmarshal empty struct.
This commit is contained in:
@@ -363,8 +363,7 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm
|
|||||||
}
|
}
|
||||||
|
|
||||||
v := v
|
v := v
|
||||||
v = reflect.any_base(v)
|
ti := reflect.type_info_base(type_info_of(v.id))
|
||||||
ti := type_info_of(v.id)
|
|
||||||
|
|
||||||
#partial switch t in ti.variant {
|
#partial switch t in ti.variant {
|
||||||
case reflect.Type_Info_Struct:
|
case reflect.Type_Info_Struct:
|
||||||
|
|||||||
@@ -349,6 +349,24 @@ unmarshal_json :: proc(t: ^testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test
|
||||||
|
unmarshal_empty_struct :: proc(t: ^testing.T) {
|
||||||
|
TestStruct :: struct {}
|
||||||
|
test := make(map[string]TestStruct)
|
||||||
|
input: = `{
|
||||||
|
"test_1": {},
|
||||||
|
"test_2": {}
|
||||||
|
}`
|
||||||
|
err := json.unmarshal(transmute([]u8)input, &test)
|
||||||
|
defer {
|
||||||
|
for k in test {
|
||||||
|
delete(k)
|
||||||
|
}
|
||||||
|
delete(test)
|
||||||
|
}
|
||||||
|
testing.expect(t, err == nil, "Expected empty struct to unmarshal without error")
|
||||||
|
}
|
||||||
|
|
||||||
@test
|
@test
|
||||||
surrogate :: proc(t: ^testing.T) {
|
surrogate :: proc(t: ^testing.T) {
|
||||||
input := `+ + * 😃 - /`
|
input := `+ + * 😃 - /`
|
||||||
|
|||||||
Reference in New Issue
Block a user