int main()
{
Json::Value a, b, c, d, e;
a = 12; //int
b = "hello";//string
c = false; //boolean
d = true; //boolean
//eΪnull
cout << "First" << endl;
cout << a.asInt() << endl;
cout << b.asString() << endl;
cout << c.asString() << endl;
cout << d.asString() << endl;
cout << e.asString() << endl;
//也可以使用复制构造函数来初始化生成JSON对象
a = Json::Value(13);
b = Json::Value("hello world");
c = Json::Value(false);
d = Json::Value(true);
e = Json::Value();
cout << "Second" << endl;
cout << a.asInt() << endl;
cout << b.asString() << endl;
cout << c.asString() << endl;
cout << d.asString() << endl;
cout << e.asString() << endl;
return 0;
}
一个非常简单的json案例,但是只要执行AsString函数就会报错,报错如下
jsoncpp包用的是vcpkg上面下载的版本。完全不知道是什么问题,python函数里面返回值要是执行AsString函数也会报一样的错误,不知道到底是什么原因