diff options
author | Milo Yip <miloyip@gmail.com> | 2014-07-06 18:48:21 +0400 |
---|---|---|
committer | Milo Yip <miloyip@gmail.com> | 2014-07-06 18:48:21 +0400 |
commit | bcd935be875353af3538253a3a282b475c71f0c4 (patch) | |
tree | 64f48f23a0970a0b69c47c003b2b7f51710a7c45 /doc | |
parent | 698496e3f37d785352d971faa3c9c46704cf12fc (diff) | |
parent | 7398f66f61f4d67563c7e7d99b3ae51c217af802 (diff) |
Merge remote-tracking branch 'origin/master'
Conflicts:
doc/stream.md
doc/tutorial.md
Diffstat (limited to 'doc')
-rw-r--r-- | doc/features.md | 12 | ||||
-rw-r--r-- | doc/stream.md | 8 | ||||
-rw-r--r-- | doc/tutorial.md | 4 |
3 files changed, 15 insertions, 9 deletions
diff --git a/doc/features.md b/doc/features.md index f5d93552..3cc63099 100644 --- a/doc/features.md +++ b/doc/features.md @@ -39,10 +39,10 @@ ## API styles * SAX (Simple API for XML) style API - * Similar to [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML), RapidJSON provides a event sequential access parser API (`GenericReader`). It also provides a generator API (`GenericWriter`) which consumes the same set of events. + * Similar to [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML), RapidJSON provides a event sequential access parser API (`rapidjson::GenericReader`). It also provides a generator API (`rapidjson::Writer`) which consumes the same set of events. * DOM (Document Object Model) style API - * Similar to [DOM](http://en.wikipedia.org/wiki/Document_Object_Model) for HTML/XML, RapidJSON can parse JSON into a DOM representation (`GenericDocument`), for easy manipulation, and finally stringify back to JSON if needed. - * The DOM style API (`GenericDocument`) is actually implemented with SAX style API (`GenericReader`). SAX is faster but sometimes DOM is easier. Users can pick their choices according to scenarios. + * Similar to [DOM](http://en.wikipedia.org/wiki/Document_Object_Model) for HTML/XML, RapidJSON can parse JSON into a DOM representation (`rapidjson::GenericDocument`), for easy manipulation, and finally stringify back to JSON if needed. + * The DOM style API (`rapidjson::GenericDocument`) is actually implemented with SAX style API (`rapidjson::GenericReader`). SAX is faster but sometimes DOM is easier. Users can pick their choices according to scenarios. ## DOM (Document) @@ -59,13 +59,13 @@ ## SAX (Writer) -* Support PrettyWriter for adding newlines and indentations. +* Support `rapidjson::PrettyWriter` for adding newlines and indentations. * Support custom precision for floating point values. ## Stream -* Support `GenericStringBuffer` for storing the output JSON as string. -* Support `FileReadStream`/`FileWriteStream` for input/output `FILE` object. +* Support `rapidjson::GenericStringBuffer` for storing the output JSON as string. +* Support `rapidjson::FileReadStream`/`rapidjson::FileWriteStream` for input/output `FILE` object. * Support custom streams. ## Memory diff --git a/doc/stream.md b/doc/stream.md index 441dbaa1..84d58bcd 100644 --- a/doc/stream.md +++ b/doc/stream.md @@ -1,6 +1,6 @@ # RapidJSON Stream -In RapidJSON, `Stream` is a concept for reading/writing JSON. Here we first show how to use streams provided. And then see how to create a custom streams. +In RapidJSON, `rapidjson::Stream` is a concept for reading/writing JSON. Here we first show how to use streams provided. And then see how to create a custom streams. ## Memory Streams @@ -73,6 +73,8 @@ However, if the JSON is big, or memory is limited, you can use `FileReadStream`. #include "rapidjson/filereadstream.h" #include <cstdio> +using namespace rapidjson; + FILE* fp = fopen("big.json", "rb"); // non-Windows use "r" char readBuffer[65536]; @@ -96,6 +98,8 @@ Apart from reading file, user can also use `FileReadStream` to read `stdin`. #include "rapidjson/filewritestream.h" #include <cstdio> +using namespace rapidjson; + Document d; d.Parse(json); // ... @@ -212,6 +216,8 @@ You can obtain the type of UTF via `UTFType GetType()`. And check whether a BOM Similarly, to choose encoding for output during runtime, we can use `AutoUTFOutputStream`. This class is not automatic *per se*. You need to specify the UTF type and whether to write BOM in runtime. ~~~~~~~~~~cpp +using namespace rapidjson; + void WriteJSONFile(FILE* fp, UTFType type, bool putBOM, const Document& d) { char writeBuffer[256]; FileWriteStream bos(fp, writeBuffer, sizeof(writeBuffer)); diff --git a/doc/tutorial.md b/doc/tutorial.md index 0b3da16d..721e7472 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -383,7 +383,7 @@ Object is a collection of key-value pairs. Each key must be a string value. The Here is an example. ~~~~~~~~~~cpp -Value contact(kObejct); +Value contact(kObject); contact.AddMember("name", "Milo", document.GetAllocator()); contact.AddMember("married", true, document.GetAllocator()); ~~~~~~~~~~ @@ -433,4 +433,4 @@ This tutorial shows the basics of DOM tree query and manipulation. There are sev 5. [Performance](performance.md) shows some in-house and third-party benchmarks. 6. [Internals](internals.md) describes some internal designs and techniques of RapidJSON. -You may also refer to the FAQ, API documentation, examples and unit tests. +You may also refer to the [FAQ](faq.md), API documentation, examples and unit tests. |