Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Document and Value in rapidjson?

Tags:

rapidjson

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?

like image 398
ggrr Avatar asked May 04 '15 10:05

ggrr


People also ask

Is RapidJSON good?

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.

What is DOM in JSON?

Document Object Model(DOM) is an in-memory representation of JSON for query and manipulation. The basic usage of DOM is described in Tutorial.

How do I use RapidJSON in Visual Studio?

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.


1 Answers

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.

like image 78
Milo Yip Avatar answered Jan 04 '23 17:01

Milo Yip