Ho seguente codice:Crea un array JSON vuoto con jsoncpp
void MyClass::myMethod(Json::Value& jsonValue_ref)
{
for (int i = 0; i <= m_stringList.size(); i++)
{
if (m_boolMarkerList[i])
{
jsonValue_ref.append(stringList[i]);
}
}
}
void MyClass::myOuterMethod()
{
Json::Value jsonRoot;
Json::Value jsonValue;
myMethod(jsonValue);
jsonRoot["somevalue"] = jsonValue;
Json::StyledWriter writer;
std::string out_string = writer.write(jsonRoot);
}
Se tutti boolMarkers sono false l'out_string è { "somevalue": null} ma io voglio che sia un array vuoto: { "somevalue" : []}
Qualcuno sa come ottenere ciò?
Grazie mille!
perché non solo 'jsonRootValue [" emptyArray "] = Json :: arrayValue'; –
Penso che forse quando ho postato questa domanda - due anni prima del tuo commento - non era possibile. –