简介
JsonCpp是一个允许操作JSON值的C++库,包括对字符串进行序列化和反序列化。 它也可以保存反序列化/序列化步骤中的现有注释,使其方便用于存储用户输入文件的格式。
编译和测试方式
1.配置编译环境
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
系统回显如下,表示运行正常。
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
......