Linux下Json库的编译及例程
从(http://jsoncpp.sourceforge.net/)下载源码包“jsoncpp-src-0.5.0.tar.gz”,解压后在其解压后目录中运行
$ scons platform=linux-gcc
编译出来的库文件在其libs/ linux-gcc-4.4.2目录下,有libjson_linux-gcc-4.4.2_libmt.so和libjson_linux-gcc-4.4.2_libmt.a。头文件在解压目录下的include中。我的jsoncpp安装在$HOME/usr/jsoncpp下。
$ mkdir ~/usr/jsoncpp
$ cp -r include ~/usr/jsoncpp
$ cp -r libs ~/usr/jsoncpp
- /*
- * test.cpp
- *
- * Created on: 2011-9-1
- * Author: will
- */
- #include <iostream>
- #include <string>
- #include "json/json.h"
- using namespace std;
- int main(void)
- {
- Json::Value root;
- Json::FastWriter fast;
- root["ModuleType"] = Json::Value("你好");
- root["ModuleCode"] = Json::Value("22");
- root["ModuleDesc"] = Json::Value("33");
- root["DateTime"] = Json::Value("44");
- root["LogType"] = Json::Value("55");
- cout<<fast.write(root)<<endl;
- return 0;
- }
- {"DateTime":"44","LogType":"55","ModuleCode":"22","ModuleDesc":"33","ModuleType":"你好"}
相关推荐
IT之家 2020-03-11
graseed 2020-10-28
zbkyumlei 2020-10-12
SXIAOYI 2020-09-16
jinhao 2020-09-07
impress 2020-08-26
liuqipao 2020-07-07
淡风wisdon大大 2020-06-06
yoohsummer 2020-06-01
chenjia00 2020-05-29
baike 2020-05-19
扭来不叫牛奶 2020-05-08
hxmilyy 2020-05-11
黎豆子 2020-05-07
xiongweiwei00 2020-04-29
Cypress 2020-04-25
冰蝶 2020-04-20