From 335d278f5ee972314b56f48892a95c999cab0501 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 21 Jan 2025 22:15:36 -0600 Subject: [PATCH] [ox/oc] Fix integer read for signed/unsigned --- deps/ox/src/ox/oc/read.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/deps/ox/src/ox/oc/read.hpp b/deps/ox/src/ox/oc/read.hpp index 30638c80..763e5102 100644 --- a/deps/ox/src/ox/oc/read.hpp +++ b/deps/ox/src/ox/oc/read.hpp @@ -144,7 +144,11 @@ Error OrganicClawReader::field(const char *key, T *val) noexcept { if (jv.empty()) { *val = 0; } else if (rightType) { - *val = static_cast(jv.asUInt()); + if constexpr(ox::is_signed_v) { + *val = static_cast(jv.asInt64()); + } else { + *val = static_cast(jv.asUInt64()); + } } else { err = ox::Error(1, "Type mismatch"); } @@ -172,7 +176,8 @@ Error OrganicClawReader::field(const char *key, T *val) noexcept { err = ox::Error(1, "Type mismatch"); } } - } catch (Json::LogicError const&) { + } catch (Json::LogicError const&e) { + oxDebugf("JSON error: {}", e.what()); err = ox::Error(1, "error reading JSON data"); } ++m_fieldIt;