[ox/oc] Fix objects to always write when members of arrays

This commit is contained in:
Gary Talent 2024-01-30 21:45:58 -06:00
parent b75bbc4d20
commit 0d106bde21

View File

@ -27,7 +27,7 @@ class OrganicClawWriter {
friend Result<Buffer> writeOC(const auto &val) noexcept;
protected:
Json::Value m_json;
Json::Value m_json{Json::Value(Json::objectValue)};
Json::ArrayIndex m_fieldIt = 0;
int m_unionIdx = -1;
@ -215,7 +215,7 @@ Error OrganicClawWriter::field(const char *key, const T *val) noexcept {
OrganicClawWriter w;
ModelHandlerInterface<OrganicClawWriter, OpType::Write> handler{&w};
oxReturnError(model(&handler, val));
if (!w.m_json.isNull()) {
if (!w.m_json.empty() || m_json.isArray()) {
value(key) = w.m_json;
}
}