2
我是JSON的新手,我開始嘗試使用它,但我無法保存我的任何QJsonObject或QJsonArrays。如果我想要獲得我的QjsonObject的Json格式,我必須對它進行序列化嗎?如何序列化QJSonObject?
基本上我想在一個JSON文件來保存所有我的QJsonObsject,但它不工作,這是我的代碼
QtJson::JsonObject ingredient;
ingredient["name"] = newIngredient->GetName();
ingredient["pirce"] = newIngredient->GetPrice();
ingredient["date"] = newIngredient->GetDate();
QByteArray data = Json::serialize(ingredient);
qDebug() >> data;
像我發現沒有更多的JSON,不QJson,那麼,有沒有連載()函數我可以使用什麼? 非常感謝,如果我使用了錯誤的術語,我還在學習它們。
你的最後一行應該是讀了'qDebug()<<數據;'。你的「>>」操作符可能是問題。 – Troyseph