mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 13:00:28 +00:00
Align ignore syntax of json tags with fmt, cbor
This commit is contained in:
@@ -406,16 +406,19 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
|
||||
ti := runtime.type_info_base(type_info_of(v.id))
|
||||
info := ti.variant.(runtime.Type_Info_Struct)
|
||||
first_iteration := true
|
||||
fields_loop: for name, i in info.names {
|
||||
for name, i in info.names {
|
||||
omitempty := false
|
||||
|
||||
json_name, extra := json_name_from_tag_value(reflect.struct_tag_get(reflect.Struct_Tag(info.tags[i]), "json"))
|
||||
|
||||
if json_name == "-" {
|
||||
continue
|
||||
}
|
||||
|
||||
for flag in strings.split_iterator(&extra, ",") {
|
||||
switch flag {
|
||||
case "omitempty":
|
||||
omitempty = true
|
||||
case "ignore":
|
||||
continue fields_loop
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ utf8_string_of_multibyte_characters :: proc(t: ^testing.T) {
|
||||
@test
|
||||
struct_with_ignore_tags :: proc(t: ^testing.T) {
|
||||
My_Struct :: struct {
|
||||
a: string `json:"_,ignore"`,
|
||||
a: string `json:"-"`,
|
||||
}
|
||||
|
||||
my_struct := My_Struct{
|
||||
|
||||
Reference in New Issue
Block a user