本文整理汇总了C++中JsonObject::ToString方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonObject::ToString方法的具体用法?C++ JsonObject::ToString怎么用?C++ JsonObject::ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonObject
的用法示例。
在下文中一共展示了JsonObject::ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _ResizeFiles
void CreateProc::_ResizeFiles()
{
AppSetting *setting = AppSetting::Instance();
JsonObject *projData = new JsonObject();
projData->Add("pid",_pid);
JsonArray *pages = new JsonArray();
projData->AddObject("pages", pages);
for (auto fileItor = _filesMapping->begin(); fileItor != _filesMapping->end(); ++fileItor)
{
JsonObject *singleFile = new JsonObject();
string srcFilename = FileSys::GetFilename(fileItor->first);
string saveFilename = FileSys::GetFilename(fileItor->second);
string fileExtension = FileSys::GetFileExtension(fileItor->first);
singleFile->Add("filename", srcFilename);
singleFile->Add("imagedir", fileItor->first);
for (auto sizeItor = setting->pic_size->begin(); sizeItor != setting->pic_size->end(); ++sizeItor)
{
string optDir = FileSys::FormatDir(setting->file_save_dir + _zipRandName + "/" + sizeItor->first);
FileSys::CreateDirectory(optDir);
// Resize Picture, but need to rename
saveFilename = Assist::GenerateRandomFilename(saveFilename) + fileExtension;
OpencvEx::ResizePictureFile(fileItor->second, optDir + saveFilename, sizeItor->second->x, sizeItor->second->y);
singleFile->Add("image" + sizeItor->first, optDir + saveFilename);
}
pages->AddObject(singleFile);
safe_del(singleFile);
}
// push to server
_PushJsonToServer(projData->ToString());
safe_del(pages);
safe_del(projData);
}
示例2: test
bool test()
{
JsonObject j;
j.Add(new JsonString("first_name"), new JsonString("john"));
j.Add(new JsonString("last_name"), new JsonString("doe"));
j.Add(new JsonString("age"), new JsonNumber(22));
j.Add(new JsonString("full_time"), new JsonBool(true));
j.Add(new JsonString("work_phone"), new JsonString("123-456-7890"));
j.Add(new JsonString("mobile_phone"), new JsonNull());
JsonArray* ja1 = new JsonArray();
ja1->Add(new JsonString("orange"));
ja1->Add(new JsonString("banana"));
ja1->Add(new JsonString("apple"));
SmartPointer<JsonValue> sp1(ja1);
j.Add(new JsonString("fruits"), sp1);
JsonObject* j2 = new JsonObject();
JsonArray* ja2 = new JsonArray();
ja2->Add(new JsonString("blue"));
ja2->Add(new JsonString("red"));
ja2->Add(new JsonString("orange"));
SmartPointer<JsonValue> sp2(ja2);
j2->Add(new JsonString("colors"), sp2);
SmartPointer<JsonValue> sp3(j2);
j.Add(new JsonString("shirts"), sp3);
String result = "{\"first_name\":\"john\",\"last_name\":\"doe\","
"\"age\":22,\"full_time\":true,\"work_phone\":\"123-456-7890\","
"\"mobile_phone\":null,\"fruits\":[\"orange\",\"banana\",\"apple"
"\"],\"shirts\":{\"colors\":[\"blue\",\"red\",\"orange\"]}}";
return (result == *j.ToString());
}