Due to users' requests, RapidJSON provided official wrappers for `std::basic_istream` and `std::basic_ostream`. However, please note that the performance will be much lower than the other streams above.
## IStreamWrapper {#IStreamWrapper}
`IStreamWrapper` wraps any class drived from `std::istream`, such as `std::istringstream`, `std::stringstream`, `std::ifstream`, `std::fstream`, into RapidJSON's input stream.
~~~cpp
#include <rapidjson/document.h>
#include <rapidjson/istreamwrapper.h>
#include <fstream>
usingnamespacerapidjson;
usingnamespacestd;
ifstreamifs("test.json");
IStreamWrapperisw(ifs);
Documentd;
d.ParseStream(isw);
~~~
For classes derived from `std::wistream`, use `WIStreamWrapper`.
## OStreamWrapper {#OStreamWrapper}
Similarly, `OStreamWrapper` wraps any class derived from `std::ostream`, such as `std::ostringstream`, `std::stringstream`, `std::ofstream`, `std::fstream`, into RapidJSON's input stream.
~~~cpp
#include <rapidjson/document.h>
#include <rapidjson/ostreamwrapper.h>
#include <rapidjson/writer.h>
#include <fstream>
usingnamespacerapidjson;
usingnamespacestd;
Documentd;
d.Parse(json);
// ...
ofstreamofs("output.json");
OStreamWrapperosw(ofs);
Writer<OStreamWrapper>writer(osw);
d.Accept(writer);
~~~
For classes derived from `std::wostream`, use `WOStreamWrapper`.
# Encoded Streams {#EncodedStreams}
Encoded streams do not contain JSON itself, but they wrap byte streams to provide basic encoding/decoding function.
...
...
@@ -277,14 +329,14 @@ There are two special interface, `PutBegin()` and `PutEnd()`, which are only for