38 #endif // ifndef JSON_AMALGATED_H_INCLUDED 40 - This is a security
issue (seg-faults caused by deeply nested JSON),
41 so the
default is low.
42 - `
"failIfExtra":
false or
true`
43 - If
true, `parse()` returns
false when extra non-whitespace trails
44 the JSON value in the input
string.
45 - `
"rejectDupKeys":
false or
true`
46 - If
true, `parse()` returns
false when a key is duplicated within an
object.
48 You can examine
'settings_` yourself 49 to see the defaults. You can also write and read them just like any 53 Json::Value settings_; 56 virtual ~CharReaderBuilder(); 58 virtual CharReader *newCharReader() const; 63 bool validate(Json::Value *invalid) const;
67 Value &operator[](std::string key);
74 static void setDefaults(Json::Value *settings);
80 static void strictMode(Json::Value *settings);
88 bool JSON_API parseFromStream(CharReader::Factory const &, std::istream &, Value *root,
115 JSON_API std::istream &operator>>(std::istream &, Value &);
119 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
121 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
123 #endif // CPPTL_JSON_READER_H_INCLUDED
125 // //////////////////////////////////////////////////////////////////////
126 // End of content of file: include/json/reader.h
127 // //////////////////////////////////////////////////////////////////////
129 // //////////////////////////////////////////////////////////////////////
130 // Beginning of content of file: include/json/writer.h
131 // //////////////////////////////////////////////////////////////////////
133 // Copyright 2007-2010 Baptiste Lepilleur
134 // Distributed under MIT license, or public domain if desired and
135 // recognized in your jurisdiction.
136 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
138 #ifndef JSON_WRITER_H_INCLUDED
139 #define JSON_WRITER_H_INCLUDED
141 #if !defined(JSON_IS_AMALGAMATION)
143 #endif // if !defined(JSON_IS_AMALGAMATION)
148 // Disable warning C4251: <data member>: <type> needs to have dll-interface to
150 #if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
151 #pragma warning(push)
152 #pragma warning(disable : 4251)
153 #endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
172 class JSON_API StreamWriter
175 std::ostream *sout_; // not owned; will not delete
178 virtual ~StreamWriter();
186 virtual int write(Value const &root, std::ostream *sout) = 0;
190 class JSON_API Factory
197 virtual StreamWriter *newStreamWriter() const = 0;
204 std::string JSON_API writeString(StreamWriter::Factory const &factory, Value const &root);
221 class JSON_API StreamWriterBuilder : public StreamWriter::Factory
224 // Note: We use a Json::Value so that we can add data-members to this class
225 // without a major version bump.
243 Json::Value settings_;
245 StreamWriterBuilder();
246 virtual ~StreamWriterBuilder();
251 virtual StreamWriter *newStreamWriter() const;
256 bool validate(Json::Value *invalid) const;
259 Value &operator[](std::string key);
266 static void setDefaults(Json::Value *settings);
272 class JSON_API Writer
277 virtual std::string write(const Value &root) = 0;
289 class JSON_API FastWriter : public Writer
294 virtual ~FastWriter() {}
296 void enableYAMLCompatibility();
303 void dropNullPlaceholders();
305 void omitEndingLineFeed();
307 public: // overridden from Writer
308 virtual std::string write(const Value &root);
311 void writeValue(const Value &value);
313 std::string document_;
314 bool yamlCompatiblityEnabled_;
315 bool dropNullPlaceholders_;
316 bool omitEndingLineFeed_;
cause an exception This is a security issue(seg-faults caused by deeply nested JSON)