diff options
| author | VladPavliuk <pavliuk.vlad@gmail.com> | 2024-07-14 00:21:05 +0300 |
|---|---|---|
| committer | VladPavliuk <pavliuk.vlad@gmail.com> | 2024-07-14 00:21:05 +0300 |
| commit | 76fe5d1346e623b535d5168ec36e1254ef769c68 (patch) | |
| tree | 091ef95c907eb87046356fbc037ce151da2dda41 /core/encoding/json | |
| parent | 64ae99f016998fe78a5a0304767463c46050567a (diff) | |
Align ignore syntax of json tags with fmt, cbor
Diffstat (limited to 'core/encoding/json')
| -rw-r--r-- | core/encoding/json/marshal.odin | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin index 99ae81485..30426f911 100644 --- a/core/encoding/json/marshal.odin +++ b/core/encoding/json/marshal.odin @@ -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 } } |