错误:当使用simpledom rapidjson

时间:2017-05-14 21:59:51

标签: c++ json rapidjson

我只是想测试rapidjson simpledom.cpp示例that was displayed on their website,但是当我将其添加到uVision上的项目时,我会在线获得以下错误 #include "rapidjson/document.h"

error in include chain (encodings.h): expected parameter declarator
error in include chain (encodedstream.h): expected parameter declaratory

我对C ++并不太熟悉,所以看encodings.hencodedstream.h并没有启发我如何运行这个简单的例子。

并且,如果这是相关的idk,但是当我尝试编译时我也遇到以下错误:

compiling simpledom.cpp...
.\rapidjson/rapidjson.h(249): error:  #35: #error directive: Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.   
  #    error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.

如果有人能告诉我我做错了什么就会很棒!

代码

simpledom.cpp

// JSON simple example
// This example does not handle errors.

#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include <iostream>

using namespace rapidjson;

int main() {
    // 1. Parse a JSON string into DOM.
    const char* json = "{\"project\":\"rapidjson\",\"stars\":10}";
    Document d;
    d.Parse(json);

    // 2. Modify it by DOM.
    Value& s = d["stars"];
    s.SetInt(s.GetInt() + 1);

    // 3. Stringify the DOM
    StringBuffer buffer;
    Writer<StringBuffer> writer(buffer);
    d.Accept(writer);

    // Output {"project":"rapidjson","stars":11}
    std::cout << buffer.GetString() << std::endl;
    return 0;
}

0 个答案:

没有答案