From 6995d33fb1c042310e0c4bb18b8791854e705074 Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 30 Dec 2014 11:57:58 +0100 Subject: [PATCH] + fixed documentation bugs --- README.md | 8 +++++--- src/JSON.cc | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f8c81f711..d1308e017 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,10 @@ You can also use streams: ```cpp // create object from stream +std::stringstream ss; +ss << "{ \"pi\": 3.141, \"happy\": true }"; JSON j; -j << "{ \"pi\": 3.141, \"happy\": true }"; +j << ss; // write string representation to stream std::cout << j; @@ -150,8 +152,8 @@ The type of the JSON object is determined automatically by the expression to sto ```cpp /// strings std::string s1 = "Hello, world!"; -JSON js = s; -std::string s2 = j; +JSON js = s1; +std::string s2 = js; // Booleans bool b1 = true; diff --git a/src/JSON.cc b/src/JSON.cc index 0ccf5c846..ab2b5d650 100644 --- a/src/JSON.cc +++ b/src/JSON.cc @@ -1791,9 +1791,10 @@ JSON::Parser::Parser(std::istream& _is) // from http://www.manticmoo.com/articles/jeff/programming/c++/making-io-streams-efficient-in-c++.php // Don't sync C++ and C I/O std::ios_base::sync_with_stdio(false); - while(_is) { - std::getline(_is, input_line); - string_input += input_line; + while (_is) + { + std::getline(_is, input_line); + string_input += input_line; } _length = string_input.size();