mirror of
https://github.com/odin-lang/Odin.git
synced 2026-05-01 10:34:41 +00:00
Use json field tag for json.marshal
This commit is contained in:
@@ -302,7 +302,11 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
|
||||
|
||||
for name, i in info.names {
|
||||
opt_write_iteration(w, opt, i) or_return
|
||||
opt_write_key(w, opt, name) or_return
|
||||
if json_name := string(reflect.struct_tag_get(info.tags[i], "json")); json_name != "" {
|
||||
opt_write_key(w, opt, json_name) or_return
|
||||
} else {
|
||||
opt_write_key(w, opt, name) or_return
|
||||
}
|
||||
|
||||
id := info.types[i].id
|
||||
data := rawptr(uintptr(v.data) + info.offsets[i])
|
||||
|
||||
Reference in New Issue
Block a user