JsonCpp經典入門

2021-07-15 07:33:45 字數 1390 閱讀 3750

1.1.jsoncpp簡介

json is a lightweight data-interchange format. it can represent numbers, strings, ordered sequences of values, and collections of name/value pairs.

jsoncpp is a c++ library that allows manipulating json values, including serialization and deserialization to and from strings. it can also preserve existing comment in unserialization/serialization steps, ****** it a convenient format to store user input files.

1.2.jsoncpp環境搭建

1.2.2.qt中jsoncpp安裝

① 解壓jsoncpp-master.zip包

② 在根目錄下,執行python amalgamate.py

③ 在根目錄中生成dist資料夾包含三個檔案dist/json/json-forwards.h dist/json/json.h dist/json.cpp

④ 在qt工程目錄下,生成json資料夾,並拷貝json目錄下。

⑤ 在qt工程中新增現有檔案即可。

1.3.1.寫

#include 

#include

#include "json/json.h"

using

namespace json;

using

namespace

std;

#if 0

, ]}

}#endif

void writejson()

int main()

1.3.2.讀
#include 

#include

#include "json/json.h"

using

namespace json;

using

namespace

std;

#if 0

, ]}

}#endif

void readjson()

reader reader;

value root;

if(reader.parse(is,root))

jsoncpp 安裝入門

使用cmake安裝 cd jsoncpp 1.8.0 mkdir p build debug cd build debug cmake dcmake build type release dbuild static libs off dbuild shared libs on darchive in...

演算法入門經典

有n盞燈,編號為1 n。第1個人把所有燈開啟,第2個人按下所有編號為2 的倍數的開關 這些燈將被關掉 第3個人按下所有編號為3的倍數的開關 其中關掉的燈 將被開啟,開著的燈將被關閉 依此類推。一共有k個人,問最後有哪些燈開著?輸 入n和k,輸出開著的燈的編號。k n 1000。樣例輸入 7 3樣例輸...

經典入門 排序

for int i 0 i假如修改題目中n的取值範圍,使其最大能達到10000 那就要用快速排序法。此時直接呼叫快速排序的庫函式。include includeusing namespace std int main int main sort buf,buf n,cmp cmp返回true 表示第...