[ox/oc] Fix integer read for signed/unsigned

This commit is contained in:
Gary Talent 2025-01-21 22:15:36 -06:00
parent f987b02c65
commit 335d278f5e

View File

@ -144,7 +144,11 @@ Error OrganicClawReader::field(const char *key, T *val) noexcept {
if (jv.empty()) {
*val = 0;
} else if (rightType) {
*val = static_cast<T>(jv.asUInt());
if constexpr(ox::is_signed_v<T>) {
*val = static_cast<T>(jv.asInt64());
} else {
*val = static_cast<T>(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;