最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C++中rapidjson組裝繼續(xù)簡化的方法

 更新時間:2019年04月08日 11:25:15   作者:stpeace  
今天小編就為大家分享一篇關(guān)于C++中rapidjson組裝繼續(xù)簡化的方法,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧

rapidjson組裝繼續(xù)簡化------人生苦短,我用rapidjson

看最簡單的:

#include <iostream>
#include <stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<sstream>
// 請自己下載開源的rapidjson
#include "rapidjson/prettywriter.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
#include "rapidjson/memorystream.h"
using namespace std;
using rapidjson::Document;
using rapidjson::StringBuffer;
using rapidjson::Writer;
using namespace rapidjson;
void test()
{
 Document document;
 document.SetObject();
 Document::AllocatorType& allocator = document.GetAllocator();
 Value object(rapidjson::kObjectType);
 document.AddMember("age", 29, allocator);
 document.AddMember("name", "taoge", allocator);
 StringBuffer buffer;
 Writer<StringBuffer> writer(buffer);
 document.Accept(writer);
 string str = buffer.GetString();
 cout << str << endl;
}
int main(int argc, char *argv[])
{
 test();
 return 0;
}

結(jié)果:

{"age":29,"name":"taoge"}

再看數(shù)組:

#include <iostream>
#include <stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<sstream>
// 請自己下載開源的rapidjson
#include "rapidjson/prettywriter.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
#include "rapidjson/memorystream.h"
using namespace std;
using rapidjson::Document;
using rapidjson::StringBuffer;
using rapidjson::Writer;
using namespace rapidjson;
void test()
{
 Document document;
 document.SetObject();
 Document::AllocatorType& allocator = document.GetAllocator();
 Value array(rapidjson::kArrayType);
 Value object(rapidjson::kObjectType);
 object.AddMember("age", 30, allocator);
 object.AddMember("name", "taoge", allocator);
 array.PushBack(object, allocator);
 document.AddMember("json", array, allocator);
 StringBuffer buffer;
 Writer<StringBuffer> writer(buffer);
 document.Accept(writer);
 string str = buffer.GetString();
 cout << str << endl;
}
int main(int argc, char *argv[])
{
 test();
 return 0;
}

結(jié)果:

{"json":[{"age":30,"name":"taoge"}]}

再來看一個:

#include <iostream>
#include <stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<sstream>
// 請自己下載開源的rapidjson
#include "rapidjson/prettywriter.h"
#include "rapidjson/rapidjson.h"
#include "rapidjson/document.h"
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
#include "rapidjson/memorystream.h"
using namespace std;
using rapidjson::Document;
using rapidjson::StringBuffer;
using rapidjson::Writer;
using namespace rapidjson;
void test()
{
 Document document;
 document.SetObject();
 Document::AllocatorType& allocator = document.GetAllocator();
 Value array(rapidjson::kArrayType);
 Value object(rapidjson::kObjectType);
 object.AddMember("age", 30, allocator);
 object.AddMember("name", "taoge", allocator);
 array.PushBack(object, allocator);
 document.AddMember("oh1", array, allocator);
 document.AddMember("oh2", "hehe", allocator);
 StringBuffer buffer;
 Writer<StringBuffer> writer(buffer);
 document.Accept(writer);
 string str = buffer.GetString();
 cout << str << endl;
}
int main(int argc, char *argv[])
{
 test();
 return 0;
}

結(jié)果:

{"oh1":[{"age":30,"name":"taoge"}],"oh2":"hehe"}

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接

相關(guān)文章

  • C 語言基礎(chǔ)之初識 C 語言常量

    C 語言基礎(chǔ)之初識 C 語言常量

    C語言中的常量分為以下幾種:字面常量、const修飾的常變量、#define定義的標識符常量等,下面我們將詳細對C語言這幾個常量做介紹,感興趣的小伙伴可以參考一下
    2021-09-09
  • 關(guān)于C++靜態(tài)數(shù)據(jù)成員的實現(xiàn)講解

    關(guān)于C++靜態(tài)數(shù)據(jù)成員的實現(xiàn)講解

    今天小編就為大家分享一篇關(guān)于關(guān)于C++靜態(tài)數(shù)據(jù)成員的實現(xiàn)講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-12-12
  • 基于C++編寫一個鍵盤提示音程序

    基于C++編寫一個鍵盤提示音程序

    首先講一下思路,這次制作的小黑子相當于鍵盤提示音,輸入J,N,T,M,會發(fā)出“雞你太美”的聲音,連續(xù)按下JNTM則會發(fā)出“你干嘛啊,哎呦”的聲音,感興趣的可以了解一下
    2023-03-03
  • C++基于hook iat改變Messagebox實例

    C++基于hook iat改變Messagebox實例

    這篇文章主要介紹了C++基于hook iat改變Messagebox的方法,以實例形式展示了針對IAT(即導入地址表)以及hook的操作,有助于深入理解Windows程序設(shè)計原理,需要的朋友可以參考下
    2014-10-10
  • 淺析C++中的動態(tài)內(nèi)存分配

    淺析C++中的動態(tài)內(nèi)存分配

    這篇文章主要為大家詳細介紹了C++中動態(tài)內(nèi)存分配的相關(guān)知識,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下
    2024-03-03
  • C++實現(xiàn)LeetCode(179.最大組合數(shù))

    C++實現(xiàn)LeetCode(179.最大組合數(shù))

    這篇文章主要介紹了C++實現(xiàn)LeetCode(179.最大組合數(shù)),本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • 深入學習C語言中的函數(shù)指針和左右法則

    深入學習C語言中的函數(shù)指針和左右法則

    這篇文章主要介紹了深入學習C語言中的函數(shù)指針和左右法則,左右法則是一種常用的C指針聲明,需要的朋友可以參考下
    2015-08-08
  • 匯編語言rep movsd 的使用詳解

    匯編語言rep movsd 的使用詳解

    rep movsd 每次ecx!=0便執(zhí)行movsd ,然后ecx=ecx-1 movsd移動ds:[si] 到es:[di],在32位匯編下可以用esi代替si,edi代替di
    2013-09-09
  • Qt中PaintEvent繪制實時波形圖的實現(xiàn)示例

    Qt中PaintEvent繪制實時波形圖的實現(xiàn)示例

    本文主要介紹了Qt中PaintEvent繪制實時波形圖的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-06-06
  • C++中字符串與整型及浮點型轉(zhuǎn)換全攻略

    C++中字符串與整型及浮點型轉(zhuǎn)換全攻略

    C++算法刷題等過程中經(jīng)常會遇到字符串與數(shù)字類型的轉(zhuǎn)換,在這其中雖然樸素的算法有不少,但是對于double等類型還是可以說遇到一些麻煩,所以今天就來說說使用C++標準庫中的函數(shù)實現(xiàn)這些功能。感興趣的小伙伴一起參與閱讀吧
    2021-09-09

最新評論

珠海市| 高清| 通江县| 高安市| 太仆寺旗| 彰武县| 疏附县| 贺兰县| 剑川县| 庆云县| 张北县| 沂水县| 伊吾县| 长汀县| 宜章县| 玉屏| 潮州市| 江华| 新安县| 宜宾县| 弥渡县| 墨竹工卡县| 天峨县| 墨竹工卡县| 亳州市| 定襄县| 新疆| 洛川县| 霞浦县| 运城市| 舟曲县| 隆化县| 元谋县| 灵川县| 兴国县| 翁牛特旗| 徐汇区| 双江| 凭祥市| 张北县| 三台县|