diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-01-06 09:33:42 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-06 09:33:42 +0000 |
| commit | c7739de891902aef45cf8be83d5a2ab18d43a5e5 (patch) | |
| tree | 309a3772263076cade004bc996f25eef30b6810d /core/encoding | |
| parent | 16acb342d1daa53a53d1c71feebb3ef894719f15 (diff) | |
| parent | 87c159c69fd699312fa014700c03f43188dd0728 (diff) | |
Merge pull request #4634 from dozn/patch-1
Use Struct Tags For Embedded (with `using`) Structs When Unmarshalling JSON
Diffstat (limited to 'core/encoding')
| -rw-r--r-- | core/encoding/json/unmarshal.odin | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/encoding/json/unmarshal.odin b/core/encoding/json/unmarshal.odin index c70b8d39a..57371e360 100644 --- a/core/encoding/json/unmarshal.odin +++ b/core/encoding/json/unmarshal.odin @@ -439,7 +439,7 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm use_field_idx := -1 for field, field_idx in fields { - tag_value := string(reflect.struct_tag_get(field.tag, "json")) + tag_value := reflect.struct_tag_get(field.tag, "json") json_name, _ := json_name_from_tag_value(tag_value) if key == json_name { use_field_idx = field_idx @@ -470,7 +470,7 @@ unmarshal_object :: proc(p: ^Parser, v: any, end_token: Token_Kind) -> (err: Unm } } - if field.name == key { + if field.name == key || (field.tag != "" && reflect.struct_tag_get(field.tag, "json") == key) { offset = field.offset type = field.type found = true |