Мне нужно изменить данные JSON в другую схему, используя RapidJson. Я могу изменить имя и значение объекта Value, но я не смог найти правильные примеры, чтобы изменить JSON, переставив узлы.
Я попытался создать новый документ и добавить значение, взятое из другого документа, но оно не работает.
rapidjson::Document doc1, doc2;
rapidjson::Document::AllocatorType& alloc = doc1.GetAllocator();
doc1.Parse(str); // str contains the JSON data
Value statusObj(doc1["status"], alloc);
Value resultsObj(doc1["area_data"]["update_results"], alloc);
doc2.SetObject();
doc2.AddMember("status", statusObj, alloc);
doc2.AddMember("results", resultsObj, alloc);
//doc1 - This is the inout JSON
{
"status": {},
"area_data":
{
""
"update_results":[]
}
}
//doc2 - This is what am trying to create
{
"status": {},
"results":[] //update_results from doc 1
}