mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +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))
|
ti := runtime.type_info_base(type_info_of(v.id))
|
||||||
info := ti.variant.(runtime.Type_Info_Struct)
|
info := ti.variant.(runtime.Type_Info_Struct)
|
||||||
first_iteration := true
|
first_iteration := true
|
||||||
fields_loop: for name, i in info.names {
|
for name, i in info.names {
|
||||||
omitempty := false
|
omitempty := false
|
||||||
|
|
||||||
json_name, extra := json_name_from_tag_value(reflect.struct_tag_get(reflect.Struct_Tag(info.tags[i]), "json"))
|
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, ",") {
|
for flag in strings.split_iterator(&extra, ",") {
|
||||||
switch flag {
|
switch flag {
|
||||||
case "omitempty":
|
case "omitempty":
|
||||||
omitempty = true
|
omitempty = true
|
||||||
case "ignore":
|
|
||||||
continue fields_loop
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ utf8_string_of_multibyte_characters :: proc(t: ^testing.T) {
|
|||||||
@test
|
@test
|
||||||
struct_with_ignore_tags :: proc(t: ^testing.T) {
|
struct_with_ignore_tags :: proc(t: ^testing.T) {
|
||||||
My_Struct :: struct {
|
My_Struct :: struct {
|
||||||
a: string `json:"_,ignore"`,
|
a: string `json:"-"`,
|
||||||
}
|
}
|
||||||
|
|
||||||
my_struct := My_Struct{
|
my_struct := My_Struct{
|
||||||
|
|||||||
Reference in New Issue
Block a user