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

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

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

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

看最簡(jiǎn)單的:

#include <iostream>
#include <stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<sstream>
// 請(qǐng)自己下載開(kāi)源的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>
// 請(qǐng)自己下載開(kāi)源的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"}]}

再來(lái)看一個(gè):

#include <iostream>
#include <stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<sstream>
// 請(qǐng)自己下載開(kāi)源的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é)

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

相關(guān)文章

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

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

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

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

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

    基于C++編寫(xiě)一個(gè)鍵盤(pán)提示音程序

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

    C++基于hook iat改變Messagebox實(shí)例

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

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

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

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

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

    深入學(xué)習(xí)C語(yǔ)言中的函數(shù)指針和左右法則

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

    匯編語(yǔ)言rep movsd 的使用詳解

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

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

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

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

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

最新評(píng)論

恭城| 五家渠市| 上饶县| 太白县| 浪卡子县| 安庆市| 临澧县| 平阳县| 辛集市| 金川县| 中超| 吉安县| 墨江| 东宁县| 当阳市| 台东县| 潮安县| 孟村| 循化| 大庆市| 临清市| 临澧县| 茶陵县| 上饶县| 和龙市| 奎屯市| 盐亭县| 临湘市| 三门峡市| 南康市| 旅游| 石首市| 巴林右旗| 富源县| 民权县| 蒙阴县| 平谷区| 高阳县| 屯昌县| 深州市| 桂阳县|