0

该文件位于 /home/shivang/Desktop 位置,文件名为 sh1.cpp 该文件的源代码如下

#include iostream
#include json/json.h
#include json/reader.h

using namespace std;
using namespace Json;

int main() {
    std::string example = "{\"array\":[\"item1\", \"item2\"], \"not an array\":\"asdf\"}";
    Value value;
    Reader reader;

    bool parsed = reader.parse(example, value, false);
    std::cout << parsed;

    cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
    return 0;
}

显示以下错误消息。

/home/shivang/Desktop/sh1.cpp: In function ‘int main()’:
/home/shivang/Desktop/sh1.cpp:10:2: error: ‘Value’ was not declared in this scope
/home/shivang/Desktop/sh1.cpp:10:8: error: expected ‘;’ before ‘value’
/home/shivang/Desktop/sh1.cpp:11:2: error: ‘Reader’ was not declared in this scope
/home/shivang/Desktop/sh1.cpp:11:9: error: expected ‘;’ before ‘reader’
/home/shivang/Desktop/sh1.cpp:13:16: error: ‘reader’ was not declared in this scope
/home/shivang/Desktop/sh1.cpp:13:38: error: ‘value’ was not declared in this scope

配置gcc版本4.5.2(Ubuntu/Linaro 4.5.2-8ubuntu4)jsoncpp-src-0.5.0 eclipse-cpp-helios-SR2-linux-gtk

4

1 回答 1

0

我以前从未使用过 Json 或 C++。但是在谷歌上搜索了一下,我就到了这个页面。我认为将以下行添加到您的包含列表中应该会有所帮助:

#include <json/value.h>
于 2011-05-24T20:58:55.057 回答