2

我定义了一个这样的 template.json 文件:

         {  "id":1,
            "licence":
            {
                "province":"BeiJin",
                "number":"RB03718"
            }
         }

像这样定义cars.json:

{
"cars":[]
}

然后全部加载

 rapidjson::Document car,cars;
 loadJson(car, "template.json");   //load the json file from disk
 loadJson(cars,"cars.json");
 auto & allocator=cars.GetAllocator();
 cars.PushBack(car  , allocator);

尝试在汽车中获得类似的东西

  {
            "car": [
                  {  "id":1,
                     "licence":
                     {
                       "province":"BeiJin",
                       "number":"RB03718"
                     }
                  }
                  ]
    }

但随着汽车文件脱离生命周期。汽车数组中的元素发生故障。我该如何解决这个问题?

4

0 回答 0