From 48e33b0043a66156d1091f341ade7712a29fe8ba Mon Sep 17 00:00:00 2001 From: jkenda Date: Wed, 19 Feb 2025 19:14:55 +0100 Subject: [PATCH] marshal_struct_fields: fixed checking the wrong value --- core/encoding/json/marshal.odin | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin index 63194546eda..8cfcdfcfefc 100644 --- a/core/encoding/json/marshal.odin +++ b/core/encoding/json/marshal.odin @@ -377,17 +377,17 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err: } } - if omitnil && reflect.is_nil(v) { + id := info.types[i].id + data := rawptr(uintptr(v.data) + info.offsets[i]) + the_value := any{data, id} + + if omitnil && reflect.is_nil(the_value) { continue } - if omitempty && reflect.length(v) == 0 { + if omitempty && reflect.length(the_value) == 0 { continue } - id := info.types[i].id - data := rawptr(uintptr(v.data) + info.offsets[i]) - the_value := any{data, id} - opt_write_iteration(w, opt, first_iteration) or_return first_iteration = false if json_name != "" {