Perform a copy of Document object of rapidjson

后端 未结 4 595
小鲜肉
小鲜肉 2020-12-20 20:32

I\'m making a class and I want to return my class inside a method. My class has a rapidjson::Document object.

You can see the previous problems here: L

4条回答
  •  轮回少年
    2020-12-20 20:49

    I created this method to copy document object and it works fine for me:

    static void copyDocument(rapidjson::Document & newDocument, rapidjson::Document & copiedDocument) {
        rapidjson::StringBuffer strbuf;
        rapidjson::Writer writer(strbuf);
        newDocument.Accept(writer);
        std::string str = strbuf.GetString();
        copiedDocument.Parse<0>(str.c_str());
    }
    

提交回复
热议问题