blob: 0b38176491365e89278cdf59f45069bbd3c11faf [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)
Jordan Bayles00b979f2019-09-25 14:04:53 -070010#include "json_features.h"
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100011#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 */
Jordan Baylesf34bf242019-10-11 11:19:00 -070035
36class JSONCPP_DEPRECATED(
37 "Use CharReader and CharReaderBuilder instead.") JSON_API Reader {
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100038public:
39 typedef char Char;
Aaron Jacobs11086dd2014-09-15 10:15:29 +100040 typedef const Char* Location;
Christopher Dunn6d135cb2007-06-13 15:51:04 +000041
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100042 /** \brief An error tagged with where in the JSON text it was encountered.
43 *
44 * The offsets give the [start, limit) range of bytes within the text. Note
45 * that this is bytes, not codepoints.
Christopher Dunn6d135cb2007-06-13 15:51:04 +000046 */
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100047 struct StructuredError {
Christopher Dunnd4513fc2016-02-06 09:25:20 -060048 ptrdiff_t offset_start;
49 ptrdiff_t offset_limit;
Billy Donahue1c2ed7a2019-01-17 16:35:29 -050050 String message;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100051 };
52
Billy Donahue483eba82019-07-14 18:41:48 -040053 /** \brief Constructs a Reader allowing all features for parsing.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100054 */
Jordan Baylesf34bf242019-10-11 11:19:00 -070055 JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100056 Reader();
57
Billy Donahue483eba82019-07-14 18:41:48 -040058 /** \brief Constructs a Reader allowing the specified feature set for parsing.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100059 */
Jordan Baylesf34bf242019-10-11 11:19:00 -070060 JSONCPP_DEPRECATED("Use CharReader and CharReaderBuilder instead")
Aaron Jacobs11086dd2014-09-15 10:15:29 +100061 Reader(const Features& features);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100062
63 /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
64 * document.
Billy Donahue483eba82019-07-14 18:41:48 -040065 *
66 * \param document UTF-8 encoded string containing the document
67 * to read.
68 * \param[out] root Contains the root value of the document if it
69 * was successfully parsed.
70 * \param collectComments \c true to collect comment and allow writing
71 * them back during serialization, \c false to
72 * discard comments. This parameter is ignored
73 * if Features::allowComments_ is \c false.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100074 * \return \c true if the document was successfully parsed, \c false if an
75 * error occurred.
76 */
Jordan Bayles81ae1d52019-09-16 12:37:14 -070077 bool parse(const std::string& document, Value& root,
78 bool collectComments = true);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100079
80 /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
Billy Donahue483eba82019-07-14 18:41:48 -040081 * document.
82 *
83 * \param beginDoc Pointer on the beginning of the UTF-8 encoded
84 * string of the document to read.
85 * \param endDoc Pointer on the end of the UTF-8 encoded string
86 * of the document to read. Must be >= beginDoc.
87 * \param[out] root Contains the root value of the document if it
88 * was successfully parsed.
89 * \param collectComments \c true to collect comment and allow writing
90 * them back during serialization, \c false to
91 * discard comments. This parameter is ignored
92 * if Features::allowComments_ is \c false.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100093 * \return \c true if the document was successfully parsed, \c false if an
Billy Donahue483eba82019-07-14 18:41:48 -040094 * error occurred.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100095 */
Jordan Bayles81ae1d52019-09-16 12:37:14 -070096 bool parse(const char* beginDoc, const char* endDoc, 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&).
Jordan Baylesf34bf242019-10-11 11:19:00 -0700101 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 */
Jordan Baylesf34bf242019-10-11 11:19:00 -0700111 JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
112 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
aliha472adb62019-08-26 15:37:05 -0400123 /** \brief Returns a vector of structured errors encountered 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
Jordan Baylesf34bf242019-10-11 11:19:00 -0700192 bool readToken(Token& token);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000193 void skipSpaces();
dota17db61dba2019-09-17 01:35:48 +0800194 bool match(const Char* pattern, int patternLength);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000195 bool readComment();
196 bool readCStyleComment();
197 bool readCppStyleComment();
198 bool readString();
199 void readNumber();
200 bool readValue();
Jordan Baylesf34bf242019-10-11 11:19:00 -0700201 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);
206 bool decodeString(Token& token, String& decoded);
207 bool decodeDouble(Token& token);
208 bool decodeDouble(Token& token, Value& decoded);
209 bool decodeUnicodeCodePoint(Token& token, Location& current, Location end,
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000210 unsigned int& unicode);
Jordan Baylesf34bf242019-10-11 11:19:00 -0700211 bool decodeUnicodeEscapeSequence(Token& token, Location& current,
Jordan Bayles81ae1d52019-09-16 12:37:14 -0700212 Location end, unsigned int& unicode);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500213 bool addError(const String& message, Token& token, Location extra = nullptr);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000214 bool recoverFromError(TokenType skipUntilToken);
Jordan Bayles81ae1d52019-09-16 12:37:14 -0700215 bool addErrorAndRecover(const String& message, Token& token,
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000216 TokenType skipUntilToken);
217 void skipUntilSpace();
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000218 Value& currentValue();
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000219 Char getNextChar();
Jordan Baylesf34bf242019-10-11 11:19:00 -0700220 void getLocationLineAndColumn(Location location, int& line,
221 int& column) const;
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500222 String getLocationLineAndColumn(Location location) const;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000223 void addComment(Location begin, Location end, CommentPlacement placement);
Jordan Baylesf34bf242019-10-11 11:19:00 -0700224 void skipCommentTokens(Token& token);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000225
damiramef16a352017-08-02 22:44:42 -0700226 static bool containsNewLine(Location begin, Location end);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500227 static String normalizeEOL(Location begin, Location end);
damiramef16a352017-08-02 22:44:42 -0700228
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000229 typedef std::stack<Value*> Nodes;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000230 Nodes nodes_;
231 Errors errors_;
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500232 String document_;
Hans Johnsone817e4f2019-01-14 17:09:22 -0600233 Location begin_{};
234 Location end_{};
235 Location current_{};
236 Location lastValueEnd_{};
237 Value* lastValue_{};
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500238 String commentsBefore_;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000239 Features features_;
Hans Johnsone817e4f2019-01-14 17:09:22 -0600240 bool collectComments_{};
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400241}; // Reader
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600242
243/** Interface for reading JSON from a char array.
244 */
245class JSON_API CharReader {
246public:
Hans Johnsone3e05c72019-01-14 17:09:26 -0600247 virtual ~CharReader() = default;
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600248 /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
Billy Donahue483eba82019-07-14 18:41:48 -0400249 * document. The document must be a UTF-8 encoded string containing the
250 * document to read.
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600251 *
Billy Donahue483eba82019-07-14 18:41:48 -0400252 * \param beginDoc Pointer on the beginning of the UTF-8 encoded string
253 * of the document to read.
254 * \param endDoc Pointer on the end of the UTF-8 encoded string of the
255 * document to read. Must be >= beginDoc.
256 * \param[out] root Contains the root value of the document if it was
257 * successfully parsed.
258 * \param[out] errs Formatted error messages (if not NULL) a user
259 * friendly string that lists errors in the parsed
260 * document.
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600261 * \return \c true if the document was successfully parsed, \c false if an
Billy Donahue483eba82019-07-14 18:41:48 -0400262 * error occurred.
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600263 */
Jordan Baylesf34bf242019-10-11 11:19:00 -0700264 virtual bool parse(char const* beginDoc, char const* endDoc, Value* root,
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500265 String* errs) = 0;
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600266
Ben Boeckel80def662015-09-28 15:45:11 -0400267 class JSON_API Factory {
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600268 public:
Hans Johnsone3e05c72019-01-14 17:09:26 -0600269 virtual ~Factory() = default;
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600270 /** \brief Allocate a CharReader via operator new().
271 * \throw std::exception if something goes wrong (e.g. invalid settings)
272 */
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600273 virtual CharReader* newCharReader() const = 0;
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400274 }; // Factory
275}; // CharReader
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600276
Christopher Dunn66a8ba22015-02-09 01:29:43 -0600277/** \brief Build a CharReader implementation.
Billy Donahue483eba82019-07-14 18:41:48 -0400278 *
279 * Usage:
280 * \code
281 * using namespace Json;
282 * CharReaderBuilder builder;
283 * builder["collectComments"] = false;
284 * Value value;
285 * String errs;
286 * bool ok = parseFromStream(builder, std::cin, &value, &errs);
287 * \endcode
288 */
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600289class JSON_API CharReaderBuilder : public CharReader::Factory {
Christopher Dunn66a8ba22015-02-09 01:29:43 -0600290public:
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600291 // Note: We use a Json::Value so that we can add data-members to this class
292 // without a major version bump.
293 /** Configuration of this builder.
Billy Donahue483eba82019-07-14 18:41:48 -0400294 * These are case-sensitive.
295 * Available settings (case-sensitive):
296 * - `"collectComments": false or true`
297 * - true to collect comment and allow writing them back during
298 * serialization, false to discard comments. This parameter is ignored
299 * if allowComments is false.
300 * - `"allowComments": false or true`
301 * - true if comments are allowed.
Jacob Bundgaard01db7b72019-10-16 17:07:41 +0200302 * - `"allowTrailingCommas": false or true`
303 * - true if trailing commas in objects and arrays are allowed.
Billy Donahue483eba82019-07-14 18:41:48 -0400304 * - `"strictRoot": false or true`
305 * - true if root must be either an array or an object value
306 * - `"allowDroppedNullPlaceholders": false or true`
307 * - true if dropped null placeholders are allowed. (See
308 * StreamWriterBuilder.)
309 * - `"allowNumericKeys": false or true`
310 * - true if numeric object keys are allowed.
311 * - `"allowSingleQuotes": false or true`
312 * - true if '' are allowed for strings (both keys and values)
313 * - `"stackLimit": integer`
314 * - Exceeding stackLimit (recursive depth of `readValue()`) will cause an
315 * exception.
316 * - This is a security issue (seg-faults caused by deeply nested JSON), so
317 * the default is low.
318 * - `"failIfExtra": false or true`
319 * - If true, `parse()` returns false when extra non-whitespace trails the
320 * JSON value in the input string.
321 * - `"rejectDupKeys": false or true`
322 * - If true, `parse()` returns false when a key is duplicated within an
323 * object.
324 * - `"allowSpecialFloats": false or true`
325 * - If true, special float values (NaNs and infinities) are allowed and
326 * their values are lossfree restorable.
327 *
328 * You can examine 'settings_` yourself to see the defaults. You can also
329 * write and read them just like any JSON Value.
330 * \sa setDefaults()
331 */
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600332 Json::Value settings_;
Christopher Dunn66a8ba22015-02-09 01:29:43 -0600333
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600334 CharReaderBuilder();
Hans Johnson2853b1c2019-01-11 13:58:53 -0600335 ~CharReaderBuilder() override;
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600336
Hans Johnson2853b1c2019-01-11 13:58:53 -0600337 CharReader* newCharReader() const override;
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600338
Christopher Dunnf757c182015-02-09 18:24:56 -0600339 /** \return true if 'settings' are legal and consistent;
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600340 * otherwise, indicate bad settings via 'invalid'.
341 */
342 bool validate(Json::Value* invalid) const;
Christopher Dunnc312dd52015-03-04 14:56:37 -0600343
344 /** A simple way to update a specific setting.
345 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500346 Value& operator[](const String& key);
Christopher Dunnc312dd52015-03-04 14:56:37 -0600347
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600348 /** Called by ctor, but you can use this to reset settings_.
349 * \pre 'settings' != NULL (but Json::null is fine)
Christopher Dunn3cf91752015-02-09 18:16:24 -0600350 * \remark Defaults:
Christopher Dunn56650e82015-04-20 13:10:31 -0700351 * \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600352 */
353 static void setDefaults(Json::Value* settings);
Christopher Dunn3cf91752015-02-09 18:16:24 -0600354 /** Same as old Features::strictMode().
355 * \pre 'settings' != NULL (but Json::null is fine)
356 * \remark Defaults:
Christopher Dunn56650e82015-04-20 13:10:31 -0700357 * \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
Christopher Dunn3cf91752015-02-09 18:16:24 -0600358 */
359 static void strictMode(Json::Value* settings);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000360};
361
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600362/** Consume entire stream and use its begin/end.
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400363 * Someday we might have a real StreamReader, but for now this
364 * is convenient.
365 */
Jordan Baylesf34bf242019-10-11 11:19:00 -0700366bool JSON_API parseFromStream(CharReader::Factory const&, IStream&, Value* root,
Jordan Bayles645250b2019-07-10 18:56:30 -0700367 String* errs);
Christopher Dunn2c1197c2015-01-29 14:29:40 -0600368
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000369/** \brief Read from 'sin' into 'root'.
Billy Donahue483eba82019-07-14 18:41:48 -0400370 *
371 * Always keep comments from the input JSON.
Jordan Bayles7b286982019-08-13 22:41:43 -0700372 *
Billy Donahue483eba82019-07-14 18:41:48 -0400373 * This can be used to read a file into a particular sub-object.
374 * For example:
375 * \code
376 * Json::Value root;
377 * cin >> root["dir"]["file"];
378 * cout << root;
379 * \endcode
380 * Result:
381 * \verbatim
382 * {
383 * "dir": {
384 * "file": {
385 * // The input stream JSON would be nested here.
386 * }
387 * }
388 * }
389 * \endverbatim
390 * \throw std::exception on parse error.
391 * \see Json::operator<<()
392 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500393JSON_API IStream& operator>>(IStream&, Value&);
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000394
395} // namespace Json
396
Sergiy80d6e666f2016-12-03 22:29:14 +0200397#pragma pack(pop)
398
Baptiste Lepilleureafd7022013-05-08 20:21:11 +0000399#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000400#pragma warning(pop)
Baptiste Lepilleureafd7022013-05-08 20:21:11 +0000401#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
402
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000403#endif // CPPTL_JSON_READER_H_INCLUDED