aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-04-27 05:24:59 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-04-27 05:24:59 -0400
commit309a770cbf49ef950a9c9e02ccfaced57f59e73a (patch)
treec69895582bdffaa5d8c333c57ff6ad5a270c664d
parentf745fff640ab1582bdfdd18a7239c58fa37db753 (diff)
Fix `omitempty` in `json.marshal`
-rw-r--r--core/encoding/json/marshal.odin2
-rw-r--r--core/encoding/json/unmarshal.odin2
2 files changed, 2 insertions, 2 deletions
diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin
index 04ef6d434..f45cdb1f1 100644
--- a/core/encoding/json/marshal.odin
+++ b/core/encoding/json/marshal.odin
@@ -420,7 +420,7 @@ marshal_to_writer :: proc(w: io.Writer, v: any, opt: ^Marshal_Options) -> (err:
data := rawptr(uintptr(v.data) + info.offsets[i])
the_value := any{data, id}
- if is_omitempty(the_value) {
+ if omitempty && is_omitempty(the_value) {
continue
}
diff --git a/core/encoding/json/unmarshal.odin b/core/encoding/json/unmarshal.odin
index 691303521..eb59e7838 100644
--- a/core/encoding/json/unmarshal.odin
+++ b/core/encoding/json/unmarshal.odin
@@ -348,7 +348,7 @@ json_name_from_tag_value :: proc(value: string) -> (json_name, extra: string) {
json_name = value
if comma_index := strings.index_byte(json_name, ','); comma_index >= 0 {
json_name = json_name[:comma_index]
- extra = json_name[comma_index:]
+ extra = value[1 + comma_index:]
}
return
}