華為云計算 云知識 JsonCpp如何配置
JsonCpp如何配置

簡介

JsonCpp是一個允許操作JSON值的C++庫,包括對字符串進行序列化和反序列化。 它也可以保存反序列化/序列化步驟中的現有注釋,使其方便用于存儲用戶輸入文件的格式。

編譯和測試方式

1.配置編譯環(huán)境

1)安裝wget工具。

yum install wget -y

2)安裝或者升級cmake版本到3.1.0或更高版本。

cd /usr/local/src

yum remove cmake cmake-data

wget https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz

tar -zxvf cmake-3.9.2.tar.gz

cd cmake-3.9.2

./configure

make && make install

2.獲取源碼

獲取“jsoncpp-1.8.4”源碼包。

cd /usr/local/src

wget https://github.com/open-source-parsers/jsoncpp/archive/1.8.4.tar.gz

3.編譯和安裝

1)解壓軟件包。

tar -zxvf 1.8.4.tar.gz

2)進入JsonCpp的安裝目錄。

cd jsoncpp-1.8.4/

3)生成Makefile文件。

cmake .

4)編譯JsonCpp。

make && make install

4.運行和驗證

1)進入JsonCpp的測試目錄。

cd src/test_lib_json

2)運行測試程序。

./jsoncpp_test

系統(tǒng)回顯如下,表示運行正常。

Testing ValueTest/checkNormalizeFloatingPointStr: OK

Testing ValueTest/memberCount: OK

Testing ValueTest/objects: OK

Testing ValueTest/arrays: OK

Testing ValueTest/arrayIssue252: OK

Testing ValueTest/null: OK

Testing ValueTest/strings: OK

Testing ValueTest/bools: OK

Testing ValueTest/integers: OK

Testing ValueTest/nonIntegers: OK

Testing ValueTest/compareNull: OK

Testing ValueTest/compareInt: OK

Testing ValueTest/compareUInt: OK

Testing ValueTest/compareDouble: OK

Testing ValueTest/compareString: OK

Testing ValueTest/compareBoolean: OK

Testing ValueTest/compareArray: OK

Testing ValueTest/compareObject: OK

Testing ValueTest/compareType: OK

Testing ValueTest/offsetAccessors: OK

Testing ValueTest/typeChecksThrowExceptions: OK

Testing ValueTest/StaticString: OK

Testing ValueTest/CommentBefore: OK

Testing ValueTest/zeroes: OK

Testing ValueTest/zeroesInKeys: OK

Testing ValueTest/specialFloats: OK

......