Browse Source

Use Struct Tags For Embedded (with `using`) Structs When Unmarshalling JSON

A fix for https://github.com/odin-lang/Odin/issues/4539
dozn 8 months ago
parent
commit
d22cb20d85
1 changed files with 1 additions and 1 deletions
  1. 1 1
      core/encoding/json/unmarshal.odin

+ 1 - 1
core/encoding/json/unmarshal.odin

@@ -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
 						offset = field.offset
 						type = field.type
 						type = field.type
 						found = true
 						found = true