forked from Mirrors/openclonk
Fix JSON serialization of proplists within arrays
parent
8ca3801741
commit
9b61ba468d
|
@ -228,7 +228,7 @@ StdStrBuf C4Value::ToJSON(int depth, const C4PropListStatic *ignore_reference_pa
|
|||
for (int32_t i = 0; i < Data.Array->GetSize(); i++)
|
||||
{
|
||||
if (i) DataString.Append(",");
|
||||
DataString.Append(std::move(Data.Array->GetItem(i).GetDataString(depth - 1)));
|
||||
DataString.Append(std::move(Data.Array->GetItem(i).ToJSON(depth - 1)));
|
||||
}
|
||||
DataString.AppendChar(']');
|
||||
return DataString;
|
||||
|
|
|
@ -81,4 +81,12 @@ TEST(C4ValueTest, ToJSON)
|
|||
array->SetItem(2, C4Value(3));
|
||||
EXPECT_EQ(C4Value(array).ToJSON(), R"#([1,2,3])#");
|
||||
}
|
||||
|
||||
{
|
||||
auto proplist = C4PropList::NewStatic(nullptr, nullptr, nullptr);
|
||||
proplist->SetProperty(P_Options, C4Value(123));
|
||||
auto array = new C4ValueArray(1);
|
||||
array->SetItem(0, C4Value(proplist));
|
||||
EXPECT_EQ(C4Value(array).ToJSON(), R"#([{"Options":123}])#");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue