C++ rapidjson“‘rapidjson::Document’没有名为‘GetParseErrorCode’的成员”

C++ rapidjson "‘rapidjson::Document’ has no member named ‘GetParseErrorCode'"

我正在尝试编译这个程序:

`

#include "rapidjson/document.h"
#include "rapidjson/error/en.h"
#include <stdio.h>
#include <iostream>

int main() {

    const char* json =
    "{"
        "\"hello\": \"world\","
        "\"t\": \"world\""
    "}";

    const char* msgJson =
    "{"
        "\"t\": \"MESSAGE_CREATE\","
        "\"s\": 59,"
        "\"op\": 0,"
        "\"d\":{"
            "\"tts\": false,"
            "\"timestamp\": \"2016-04-29T02:40:47.490000+00:00\","
            "\"nonce\": \"175436196699176960\","
            "\"mentions\": [ [Object] ],"
            "\"mention_everyone\": false,"
            "\"id\": \"175436191456428032\","
            "\"embeds\": [],"
            "\"edited_timestamp\": null,"
            "\"content\": \"<@174463430873317376> count stuff\","
            "\"channel_id\": \"81402706320699392\","
            "\"author\": {"
                "\"username\": \"#C2185B #AD1457 #880E4F\","
                "\"id\": \"125422419736395777\","
                "\"discriminator\": \"0672\","
                "\"avatar\": \"57ca1bf97372796648a2aac4b20614af\""
            "},"
            "\"attachments\": []"
        "}"
    "}";

    rapidjson::Document document;
    document.Parse(json);
    assert(document.IsObject());
    assert(document.HasMember("hello"));
    assert(document["hello"].IsString());
    printf("hello = %s\n", document["hello"].GetString());
    assert(document.HasMember("t"));
    assert(document["t"].IsString());
    printf("t = %s\n", document["t"].GetString());

    rapidjson::Document message;
    rapidjson::ParseResult result = message.Parse(msgJson);
    //std::cout << rapidjson::ParseErrorCode << std::endl;
    printf("%u - %s\n", (unsigned)message.GetErrorOffset(), rapidjson::GetParseError_En(message.GetParseErrorCode()));
    assert(message.IsObject());
    assert(message.HasMember("t"));
    printf("%s\n", message["t"].GetString());

    return 0;
}

`

但不断收到此错误: `

json_example.cpp: In function ‘int main()’:
json_example.cpp:53:97: error: ‘rapidjson::Document’ has no member named ‘GetParseErrorCode’
     printf("%u - %s\n", (unsigned)message.GetErrorOffset(), rapidjson::GetParseError_En(message.GetParseErrorCode()));

` 我将如何解决这个问题?因为根据 rapidjson 文档,这是正确的方法。或者有人知道用 C++ 解析 JSON 的更好方法吗?

GetParseErrorCode 应该是 GetParseError - 这是文档中的一个错误。此外,在 JSON 中,[ [ Object ] ] 不是正确的值。