c++保存数组到json文件报错?

将大型数组保存至json文件时报错,如果数组比较小就没问题。程序编译时没有问题,但是运行一直有bug。使用debug工具得到如图提示。代码如下:#include "stdafx.h"#include <iostream>#include "json\json.h"#include <string>#include <iomanip>#include <array>#include <fstream>#include "rapidjson/document.h"#include "rapidjson/filereadstream.h"#include "rapidjson/filewritestream.h"#include "rapidjson/prettywriter.h"#include "rapidjson/stringbuffer.h"using namespace std;using namespace rapidjson;int main(){ static array<array<array<array<int, 5>, 42>, 234>, 964> list; cout << "tag_1" << endl; Document d; Document::AllocatorType &allocator = d.GetAllocator(); d.SetObject(); Value arr(kArrayType); for (unsigned int i = 0; i < list.size(); i++) { Value arr_1(kArrayType); for (unsigned int j = 0; j < list[i].size(); j++) { Value arr_2(kArrayType); for (unsigned int k = 0; k < list[i][j].size(); k++) { Value arr_3(kArrayType); for (unsigned int v = 0; v < list[i][j][k].size(); v++) { arr_3.PushBack(list[i][j][k][v], allocator); } arr_2.PushBack(arr_3, allocator); } arr_1.PushBack(arr_2, allocator); } arr.PushBack(arr_1, allocator); } d.AddMember("Array", arr, allocator); StringBuffer buffer; Writer<StringBuffer> writer(buffer); d.Accept(writer); ofstream file; file.open("C:\\Users\\super\\Desktop\\just_test.json"); file << buffer.GetString(); file.close();}

不能一次放入过多数据,建议循环写入数据,不要一次性写入。望采纳,谢谢
温馨提示:答案为网友推荐,仅供参考