blob: ce216a3dcbabfe734fdeb9aa92107f6e7ca24e4d [file] [log] [blame]
Devin Jeanpierre59e4d352017-07-21 03:44:36 -07001// Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors
Baptiste Lepilleur7469f1d2010-04-20 21:35:19 +00002// Distributed under MIT license, or public domain if desired and
3// recognized in your jurisdiction.
4// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
5
Christopher Dunn6d135cb2007-06-13 15:51:04 +00006#ifndef CPPTL_JSON_READER_H_INCLUDED
Aaron Jacobs9fa4e842014-07-01 08:48:54 +10007#define CPPTL_JSON_READER_H_INCLUDED
Christopher Dunn6d135cb2007-06-13 15:51:04 +00008
Baptiste Lepilleureadc4782011-05-02 21:09:30 +00009#if !defined(JSON_IS_AMALGAMATION)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100010#include "features.h"
11#include "value.h"
Baptiste Lepilleureadc4782011-05-02 21:09:30 +000012#endif // if !defined(JSON_IS_AMALGAMATION)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100013#include <deque>
14#include <iosfwd>
Billy Donahueb5e1fe82018-05-20 16:55:27 -040015#include <istream>
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100016#include <stack>
17#include <string>
Christopher Dunn6d135cb2007-06-13 15:51:04 +000018
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100019// Disable warning C4251: <data member>: <type> needs to have dll-interface to
20// be used by...
Baptiste Lepilleureafd7022013-05-08 20:21:11 +000021#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100022#pragma warning(push)
23#pragma warning(disable : 4251)
Baptiste Lepilleureafd7022013-05-08 20:21:11 +000024#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
25
Sergiy80d6e666f2016-12-03 22:29:14 +020026#pragma pack(push, 8)
27
Christopher Dunn6d135cb2007-06-13 15:51:04 +000028namespace Json {
29
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100030/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
Billy Donahue483eba82019-07-14 18:41:48 -040031 * Value.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100032 *
Christopher Dunn8df98f62015-02-09 11:15:39 -060033 * \deprecated Use CharReader and CharReaderBuilder.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100034 */
Christof Krügeredb4bdb2018-01-12 21:35:17 +010035class JSON_API Reader {
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100036public:
37 typedef char Char;
Aaron Jacobs11086dd2014-09-15 10:15:29 +100038 typedef const Char* Location;
Christopher Dunn6d135cb2007-06-13 15:51:04 +000039
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100040 /** \brief An error tagged with where in the JSON text it was encountered.
41 *
42 * The offsets give the [start, limit) range of bytes within the text. Note
43 * that this is bytes, not codepoints.
Christopher Dunn6d135cb2007-06-13 15:51:04 +000044 */
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100045 struct StructuredError {
Christopher Dunnd4513fc2016-02-06 09:25:20 -060046 ptrdiff_t offset_start;
47 ptrdiff_t offset_limit;
Billy Donahue1c2ed7a2019-01-17 16:35:29 -050048 String message;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100049 };
50
Billy Donahue483eba82019-07-14 18:41:48 -040051 /** \brief Constructs a Reader allowing all features for parsing.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100052 */
Billy Donahueb5e1fe82018-05-20 16:55:27 -040053 JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100054 Reader();
55
Billy Donahue483eba82019-07-14 18:41:48 -040056 /** \brief Constructs a Reader allowing the specified feature set for parsing.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100057 */
Billy Donahueb5e1fe82018-05-20 16:55:27 -040058 JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
Aaron Jacobs11086dd2014-09-15 10:15:29 +100059 Reader(const Features& features);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100060
61 /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
62 * document.
Billy Donahue483eba82019-07-14 18:41:48 -040063 *
64 * \param document UTF-8 encoded string containing the document
65 * to read.
66 * \param[out] root Contains the root value of the document if it
67 * was successfully parsed.
68 * \param collectComments \c true to collect comment and allow writing
69 * them back during serialization, \c false to
70 * discard comments. This parameter is ignored
71 * if Features::allowComments_ is \c false.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100072 * \return \c true if the document was successfully parsed, \c false if an
73 * error occurred.
74 */
75 bool
Aaron Jacobs11086dd2014-09-15 10:15:29 +100076 parse(const std::string& document, Value& root, bool collectComments = true);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100077
78 /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
Billy Donahue483eba82019-07-14 18:41:48 -040079 * document.
80 *
81 * \param beginDoc Pointer on the beginning of the UTF-8 encoded
82 * string of the document to read.
83 * \param endDoc Pointer on the end of the UTF-8 encoded string
84 * of the document to read. Must be >= beginDoc.
85 * \param[out] root Contains the root value of the document if it
86 * was successfully parsed.
87 * \param collectComments \c true to collect comment and allow writing
88 * them back during serialization, \c false to
89 * discard comments. This parameter is ignored
90 * if Features::allowComments_ is \c false.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100091 * \return \c true if the document was successfully parsed, \c false if an
Billy Donahue483eba82019-07-14 18:41:48 -040092 * error occurred.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100093 */
Aaron Jacobs11086dd2014-09-15 10:15:29 +100094 bool parse(const char* beginDoc,
95 const char* endDoc,
96 Value& root,
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100097 bool collectComments = true);
98
99 /// \brief Parse from input stream.
100 /// \see Json::operator>>(std::istream&, Json::Value&).
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500101 bool parse(IStream& is, Value& root, bool collectComments = true);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000102
103 /** \brief Returns a user friendly string that list errors in the parsed
104 * document.
Billy Donahue483eba82019-07-14 18:41:48 -0400105 *
106 * \return Formatted error message with the list of errors with their
107 * location in the parsed document. An empty string is returned if no error
108 * occurred during parsing.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000109 * \deprecated Use getFormattedErrorMessages() instead (typo fix).
110 */
Christopher Dunned495ed2015-03-08 14:01:28 -0500111 JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500112 String getFormatedErrorMessages() const;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000113
114 /** \brief Returns a user friendly string that list errors in the parsed
115 * document.
Billy Donahue483eba82019-07-14 18:41:48 -0400116 *
117 * \return Formatted error message with the list of errors with their
118 * location in the parsed document. An empty string is returned if no error
119 * occurred during parsing.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000120 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500121 String getFormattedErrorMessages() const;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000122
123 /** \brief Returns a vector of structured erros encounted while parsing.
Billy Donahue483eba82019-07-14 18:41:48 -0400124 *
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000125 * \return A (possibly empty) vector of StructuredError objects. Currently
Billy Donahue483eba82019-07-14 18:41:48 -0400126 * only one error can be returned, but the caller should tolerate multiple
127 * errors. This can occur if the parser recovers from a non-fatal parse
128 * error and then encounters additional errors.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000129 */
130 std::vector<StructuredError> getStructuredErrors() const;
131
Mara Kimb84a39c2014-10-23 02:03:43 -0500132 /** \brief Add a semantic error message.
Billy Donahue483eba82019-07-14 18:41:48 -0400133 *
134 * \param value JSON Value location associated with the error
Mara Kimb84a39c2014-10-23 02:03:43 -0500135 * \param message The error message.
Billy Donahue483eba82019-07-14 18:41:48 -0400136 * \return \c true if the error was successfully added, \c false if the Value
137 * offset exceeds the document size.
Mara Kimb84a39c2014-10-23 02:03:43 -0500138 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500139 bool pushError(const Value& value, const String& message);
Mara Kimb84a39c2014-10-23 02:03:43 -0500140
141 /** \brief Add a semantic error message with extra context.
Billy Donahue483eba82019-07-14 18:41:48 -0400142 *
143 * \param value JSON Value location associated with the error
Mara Kimb84a39c2014-10-23 02:03:43 -0500144 * \param message The error message.
Billy Donahue483eba82019-07-14 18:41:48 -0400145 * \param extra Additional JSON Value location to contextualize the error
Mara Kimb84a39c2014-10-23 02:03:43 -0500146 * \return \c true if the error was successfully added, \c false if either
147 * Value offset exceeds the document size.
148 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500149 bool pushError(const Value& value, const String& message, const Value& extra);
Mara Kimb84a39c2014-10-23 02:03:43 -0500150
151 /** \brief Return whether there are any errors.
Billy Donahue483eba82019-07-14 18:41:48 -0400152 *
153 * \return \c true if there are no errors to report \c false if errors have
154 * occurred.
Mara Kimb84a39c2014-10-23 02:03:43 -0500155 */
156 bool good() const;
157
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000158private:
159 enum TokenType {
160 tokenEndOfStream = 0,
161 tokenObjectBegin,
162 tokenObjectEnd,
163 tokenArrayBegin,
164 tokenArrayEnd,
165 tokenString,
166 tokenNumber,
167 tokenTrue,
168 tokenFalse,
169 tokenNull,
170 tokenArraySeparator,
171 tokenMemberSeparator,
172 tokenComment,
173 tokenError
174 };
175
176 class Token {
177 public:
178 TokenType type_;
179 Location start_;
180 Location end_;
181 };
182
183 class ErrorInfo {
184 public:
185 Token token_;
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500186 String message_;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000187 Location extra_;
188 };
189
190 typedef std::deque<ErrorInfo> Errors;
191
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000192 bool readToken(Token& token);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000193 void skipSpaces();
194 bool match(Location pattern, int patternLength);
195 bool readComment();
196 bool readCStyleComment();
197 bool readCppStyleComment();
198 bool readString();
199 void readNumber();
200 bool readValue();
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000201 bool readObject(Token& token);
202 bool readArray(Token& token);
203 bool decodeNumber(Token& token);
204 bool decodeNumber(Token& token, Value& decoded);
205 bool decodeString(Token& token);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500206 bool decodeString(Token& token, String& decoded);
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000207 bool decodeDouble(Token& token);
208 bool decodeDouble(Token& token, Value& decoded);
209 bool decodeUnicodeCodePoint(Token& token,
210 Location& current,
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000211 Location end,
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000212 unsigned int& unicode);
213 bool decodeUnicodeEscapeSequence(Token& token,
214 Location& current,
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000215 Location end,
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000216 unsigned int& unicode);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500217 bool addError(const String& message, Token& token, Location extra = nullptr);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000218 bool recoverFromError(TokenType skipUntilToken);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500219 bool addErrorAndRecover(const String& message,
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000220 Token& token,
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000221 TokenType skipUntilToken);
222 void skipUntilSpace();
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000223 Value& currentValue();
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000224 Char getNextChar();
225 void
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000226 getLocationLineAndColumn(Location location, int& line, int& column) const;
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500227 String getLocationLineAndColumn(Location location) const;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000228 void addComment(Location begin, Location end, CommentPlacement placement);
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000229 void skipCommentTokens(Token& token);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000230
damiramef16a352017-08-02 22:44:42 -0700231 static bool containsNewLine(Location begin, Location end);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500232 static String normalizeEOL(Location begin, Location end);
damiramef16a352017-08-02 22:44:42 -0700233
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000234 typedef std::stack<Value*> Nodes;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000235 Nodes nodes_;
236 Errors errors_;
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500237 String document_;
Hans Johnsone817e4f2019-01-14 17:09:22 -0600238 Location begin_{};
239 Location end_{};
240 Location current_{};
241 Location lastValueEnd_{};
242 Value* lastValue_{};
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500243 String commentsBefore_;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000244 Features features_;
Hans Johnsone817e4f2019-01-14 17:09:22 -0600245 bool collectComments_{};
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400246}; // Reader
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600247
248/** Interface for reading JSON from a char array.
249 */
250class JSON_API CharReader {
251public:
Hans Johnsone3e05c72019-01-14 17:09:26 -0600252 virtual ~CharReader() = default;
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600253 /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
Billy Donahue483eba82019-07-14 18:41:48 -0400254 * document. The document must be a UTF-8 encoded string containing the
255 * document to read.
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600256 *
Billy Donahue483eba82019-07-14 18:41:48 -0400257 * \param beginDoc Pointer on the beginning of the UTF-8 encoded string
258 * of the document to read.
259 * \param endDoc Pointer on the end of the UTF-8 encoded string of the
260 * document to read. Must be >= beginDoc.
261 * \param[out] root Contains the root value of the document if it was
262 * successfully parsed.
263 * \param[out] errs Formatted error messages (if not NULL) a user
264 * friendly string that lists errors in the parsed
265 * document.
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600266 * \return \c true if the document was successfully parsed, \c false if an
Billy Donahue483eba82019-07-14 18:41:48 -0400267 * error occurred.
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600268 */
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400269 virtual bool parse(char const* beginDoc,
270 char const* endDoc,
271 Value* root,
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500272 String* errs) = 0;
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600273
Ben Boeckel80def662015-09-28 15:45:11 -0400274 class JSON_API Factory {
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600275 public:
Hans Johnsone3e05c72019-01-14 17:09:26 -0600276 virtual ~Factory() = default;
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600277 /** \brief Allocate a CharReader via operator new().
278 * \throw std::exception if something goes wrong (e.g. invalid settings)
279 */
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600280 virtual CharReader* newCharReader() const = 0;
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400281 }; // Factory
282}; // CharReader
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600283
Christopher Dunn66a8ba22015-02-09 01:29:43 -0600284/** \brief Build a CharReader implementation.
Billy Donahue483eba82019-07-14 18:41:48 -0400285 *
286 * Usage:
287 * \code
288 * using namespace Json;
289 * CharReaderBuilder builder;
290 * builder["collectComments"] = false;
291 * Value value;
292 * String errs;
293 * bool ok = parseFromStream(builder, std::cin, &value, &errs);
294 * \endcode
295 */
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600296class JSON_API CharReaderBuilder : public CharReader::Factory {
Christopher Dunn66a8ba22015-02-09 01:29:43 -0600297public:
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600298 // Note: We use a Json::Value so that we can add data-members to this class
299 // without a major version bump.
300 /** Configuration of this builder.
Billy Donahue483eba82019-07-14 18:41:48 -0400301 * These are case-sensitive.
302 * Available settings (case-sensitive):
303 * - `"collectComments": false or true`
304 * - true to collect comment and allow writing them back during
305 * serialization, false to discard comments. This parameter is ignored
306 * if allowComments is false.
307 * - `"allowComments": false or true`
308 * - true if comments are allowed.
309 * - `"strictRoot": false or true`
310 * - true if root must be either an array or an object value
311 * - `"allowDroppedNullPlaceholders": false or true`
312 * - true if dropped null placeholders are allowed. (See
313 * StreamWriterBuilder.)
314 * - `"allowNumericKeys": false or true`
315 * - true if numeric object keys are allowed.
316 * - `"allowSingleQuotes": false or true`
317 * - true if '' are allowed for strings (both keys and values)
318 * - `"stackLimit": integer`
319 * - Exceeding stackLimit (recursive depth of `readValue()`) will cause an
320 * exception.
321 * - This is a security issue (seg-faults caused by deeply nested JSON), so
322 * the default is low.
323 * - `"failIfExtra": false or true`
324 * - If true, `parse()` returns false when extra non-whitespace trails the
325 * JSON value in the input string.
326 * - `"rejectDupKeys": false or true`
327 * - If true, `parse()` returns false when a key is duplicated within an
328 * object.
329 * - `"allowSpecialFloats": false or true`
330 * - If true, special float values (NaNs and infinities) are allowed and
331 * their values are lossfree restorable.
332 *
333 * You can examine 'settings_` yourself to see the defaults. You can also
334 * write and read them just like any JSON Value.
335 * \sa setDefaults()
336 */
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600337 Json::Value settings_;
Christopher Dunn66a8ba22015-02-09 01:29:43 -0600338
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600339 CharReaderBuilder();
Hans Johnson2853b1c2019-01-11 13:58:53 -0600340 ~CharReaderBuilder() override;
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600341
Hans Johnson2853b1c2019-01-11 13:58:53 -0600342 CharReader* newCharReader() const override;
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600343
Christopher Dunnf757c182015-02-09 18:24:56 -0600344 /** \return true if 'settings' are legal and consistent;
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600345 * otherwise, indicate bad settings via 'invalid'.
346 */
347 bool validate(Json::Value* invalid) const;
Christopher Dunnc312dd52015-03-04 14:56:37 -0600348
349 /** A simple way to update a specific setting.
350 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500351 Value& operator[](const String& key);
Christopher Dunnc312dd52015-03-04 14:56:37 -0600352
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600353 /** Called by ctor, but you can use this to reset settings_.
354 * \pre 'settings' != NULL (but Json::null is fine)
Christopher Dunn3cf91752015-02-09 18:16:24 -0600355 * \remark Defaults:
Christopher Dunn56650e82015-04-20 13:10:31 -0700356 * \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600357 */
358 static void setDefaults(Json::Value* settings);
Christopher Dunn3cf91752015-02-09 18:16:24 -0600359 /** Same as old Features::strictMode().
360 * \pre 'settings' != NULL (but Json::null is fine)
361 * \remark Defaults:
Christopher Dunn56650e82015-04-20 13:10:31 -0700362 * \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
Christopher Dunn3cf91752015-02-09 18:16:24 -0600363 */
364 static void strictMode(Json::Value* settings);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000365};
366
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600367/** Consume entire stream and use its begin/end.
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400368 * Someday we might have a real StreamReader, but for now this
369 * is convenient.
370 */
371bool JSON_API parseFromStream(CharReader::Factory const&,
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500372 IStream&,
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400373 Value* root,
Jordan Bayles645250b2019-07-10 18:56:30 -0700374 String* errs);
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600375
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000376/** \brief Read from 'sin' into 'root'.
Billy Donahue483eba82019-07-14 18:41:48 -0400377 *
378 * Always keep comments from the input JSON.
379 *
380 * This can be used to read a file into a particular sub-object.
381 * For example:
382 * \code
383 * Json::Value root;
384 * cin >> root["dir"]["file"];
385 * cout << root;
386 * \endcode
387 * Result:
388 * \verbatim
389 * {
390 * "dir": {
391 * "file": {
392 * // The input stream JSON would be nested here.
393 * }
394 * }
395 * }
396 * \endverbatim
397 * \throw std::exception on parse error.
398 * \see Json::operator<<()
399 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500400JSON_API IStream& operator>>(IStream&, Value&);
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000401
402} // namespace Json
403
Sergiy80d6e666f2016-12-03 22:29:14 +0200404#pragma pack(pop)
405
Baptiste Lepilleureafd7022013-05-08 20:21:11 +0000406#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000407#pragma warning(pop)
Baptiste Lepilleureafd7022013-05-08 20:21:11 +0000408#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
409
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000410#endif // CPPTL_JSON_READER_H_INCLUDED