Seems Document can also be used as parameter in
void test(Value value);
and both Document and Value can have child value, what is the difference between them?
Is RapidJSON really fast? Yes. It may be the fastest open source JSON library. There is a benchmark for evaluating performance of C/C++ JSON libraries.
Document Object Model(DOM) is an in-memory representation of JSON for query and manipulation. The basic usage of DOM is described in Tutorial.
In Visual Studio, open the solution and in Solution Explorer, select the project that is using rapidjson and either use the main menu PROJECT Properties function, or right-click on the project and select Properties from the option menu. This will display the Properties dialog.
Firstly, the test function should not compile because Value does not support copy constructor. So you must use Value& value or const Value& value) instead.
Back to the question, Value represents a node in the DOM. Document derives from Value, and it represents the root of the DOM. Document provides functionality for parsing a JSON into the DOM, while Value cannot.
If the function does not need to call APIs dedicated for Document, such as Document::Parse(), you should use Value&. Passing a Document object to Value& parameter is OK in C++ too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With