c++ - rapidjson + c++:“abort() 已被调用”错误
问题描述
我需要在我的 C++ 程序中解析 json。我决定为此目的使用 RapidJson 库,但出现“abort() 已被调用”错误。我将代码截断为:
#include <iostream>
#include <cstdlib>
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/encodings.h"
#include "rapidjson/stringbuffer.h"
using namespace std;
using namespace rapidjson;
typedef GenericDocument<UTF16<> > WDocument;
typedef GenericValue<UTF16<> > WValue;
wchar_t request[] = L"{\"result\":\"OK\"}";
int main()
{
WDocument d;
d.Parse(request);
WValue& v = d[L"result"]; // The exception throws here
if (wcscmp(v.GetString(), L"OK"))
{
cout << "Success!" << endl;
}
else
cout << "Fail!" << endl;
system("pause");
return 0;
}
但我又得到了错误。错误在哪里?提前致谢!
解决方案
check this line:
wchar_t request[] = L"{\"result\":\"OK\"}";
there is a character before the left brace.
推荐阅读
- python - seaborn violinplot 和 boxplot 并排
- css - SASS @mixin 在 .css 文件中编译
- selenium-webdriver - 当存在两个或更多单选按钮部分时,无法找到一个部分中的单选按钮数量
- flutter - 根据闭包上下文的要求,返回类型“Null”不是“Widget”
- outlook - Office.SeriesTime TypeScript 定义缺少属性只有方法
- android - 如何使用存储在数据库中的颜色在 MPAndroidChart 中设置颜色?
- angular - 将数组分配给具有 Mock 数据的另一个数组时出现角度未定义错误
- c# - Xamarin 表单无法处理异常
- reactjs - 为什么我的 useState() 钩子没有在 useEffect() 中设置新状态?
- .net - 如何在使用 `dotnet test` 和 VS 执行测试之前运行命令?