官网
下载
readme,按照说明来,...,make出现错误,大意是g++编译器不支持-std=c++11。g++ -v,4.4.7,man g++,支持到c++0x。
找低版本0.10.5,...,make,出现错误cpp 1260行,常量超过long范围,看了下LONG_MAX,是这个样子,貌似在测试float,在后面加个.0,通过
将jsoncpp.cpp json/复制到/usr/include/
编写测试test.cpp,复制别人的。
#include <json/json.h>
#include <jsoncpp.cpp>
#include <iostream>
using namespace std;
int main()
{
string test ="{\"id\":1,\"name\":\"kurama\"}";
Json::Reader reader;
Json::Value value;
if(reader.parse(test,value)) {
if(!value["id"].isNull()) {
cout << value["id"].asInt() << endl;
cout << value["name"].asString()<< endl;
}
}
return 0;
}
g++ -Wall test.cpp
./a.out
os: centos 6.7 32bit
本文介绍了在CentOS 6.7上遇到的JSONCpp编译问题及解决方案,包括处理g++版本不支持C++11的问题,并提供了一个简单的JSONCpp使用示例。
4260

被折叠的 条评论
为什么被折叠?



