blob: 88a3b12e9ddadc8f5544d3ce86e17289d06dc02f [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 JSON_WRITER_H_INCLUDED
Aaron Jacobs9fa4e842014-07-01 08:48:54 +10007#define JSON_WRITER_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 "value.h"
Baptiste Lepilleureadc4782011-05-02 21:09:30 +000011#endif // if !defined(JSON_IS_AMALGAMATION)
Christopher Dunn177b7b82015-01-26 10:35:54 -060012#include <ostream>
Billy Donahueb5e1fe82018-05-20 16:55:27 -040013#include <string>
14#include <vector>
Christopher Dunn6d135cb2007-06-13 15:51:04 +000015
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100016// Disable warning C4251: <data member>: <type> needs to have dll-interface to
17// be used by...
Hugh Bellamy72870652017-09-16 10:01:09 +010018#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING) && defined(_MSC_VER)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100019#pragma warning(push)
20#pragma warning(disable : 4251)
Baptiste Lepilleureafd7022013-05-08 20:21:11 +000021#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
22
Sergiy80d6e666f2016-12-03 22:29:14 +020023#pragma pack(push, 8)
24
Christopher Dunn6d135cb2007-06-13 15:51:04 +000025namespace Json {
26
Aaron Jacobs9fa4e842014-07-01 08:48:54 +100027class Value;
Christopher Dunn489707f2015-01-22 15:25:30 -060028
29/**
Jordan Bayles81ae1d52019-09-16 12:37:14 -070030 *
31 * Usage:
32 * \code
33 * using namespace Json;
34 * void writeToStdout(StreamWriter::Factory const& factory, Value const& value)
35 * { std::unique_ptr<StreamWriter> const writer( factory.newStreamWriter());
36 * writer->write(value, &std::cout);
37 * std::cout << std::endl; // add lf and flush
38 * }
39 * \endcode
40 */
Christopher Dunn5fbfe3c2015-01-22 14:31:32 -060041class JSON_API StreamWriter {
42protected:
Billy Donahue1c2ed7a2019-01-17 16:35:29 -050043 OStream* sout_; // not owned; will not delete
Christopher Dunn5fbfe3c2015-01-22 14:31:32 -060044public:
Christopher Dunnc41609b2015-02-09 18:44:53 -060045 StreamWriter();
Christopher Dunn5fbfe3c2015-01-22 14:31:32 -060046 virtual ~StreamWriter();
Jordan Bayles81ae1d52019-09-16 12:37:14 -070047 /** Write Value into document as configured in sub-class.
48 * Do not take ownership of sout, but maintain a reference during function.
49 * \pre sout != NULL
50 * \return zero on success (For now, we always return zero, so check the
51 * stream instead.) \throw std::exception possibly, depending on
52 * configuration
53 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -050054 virtual int write(Value const& root, OStream* sout) = 0;
Christopher Dunn5fbfe3c2015-01-22 14:31:32 -060055
Christopher Dunn177b7b82015-01-26 10:35:54 -060056 /** \brief A simple abstract factory.
57 */
58 class JSON_API Factory {
59 public:
60 virtual ~Factory();
Christopher Dunna9e1ab32015-02-09 17:22:28 -060061 /** \brief Allocate a CharReader via operator new().
Christopher Dunna9e1ab32015-02-09 17:22:28 -060062 * \throw std::exception if something goes wrong (e.g. invalid settings)
63 */
Christopher Dunnc41609b2015-02-09 18:44:53 -060064 virtual StreamWriter* newStreamWriter() const = 0;
Billy Donahueb5e1fe82018-05-20 16:55:27 -040065 }; // Factory
66}; // StreamWriter
Christopher Dunn5fbfe3c2015-01-22 14:31:32 -060067
Christopher Dunn694dbcb2015-02-09 15:25:57 -060068/** \brief Write into stringstream, then return string, for convenience.
69 * A StreamWriter will be created from the factory, used, and then deleted.
70 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -050071String JSON_API writeString(StreamWriter::Factory const& factory,
72 Value const& root);
Christopher Dunn6065a1c2015-01-26 11:01:15 -060073
74/** \brief Build a StreamWriter implementation.
Christopher Dunn999f5912015-01-26 11:12:53 -060075
dota17abcd3f72019-09-17 01:40:35 +080076* Usage:
77* \code
78* using namespace Json;
79* Value value = ...;
80* StreamWriterBuilder builder;
81* builder["commentStyle"] = "None";
82* builder["indentation"] = " "; // or whatever you like
83* std::unique_ptr<Json::StreamWriter> writer(
84* builder.newStreamWriter());
85* writer->write(value, &std::cout);
86* std::cout << std::endl; // add lf and flush
87* \endcode
Christopher Dunn999f5912015-01-26 11:12:53 -060088*/
Christopher Dunn6065a1c2015-01-26 11:01:15 -060089class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
Christopher Dunn6065a1c2015-01-26 11:01:15 -060090public:
Christopher Dunna9e1ab32015-02-09 17:22:28 -060091 // Note: We use a Json::Value so that we can add data-members to this class
92 // without a major version bump.
93 /** Configuration of this builder.
dota17abcd3f72019-09-17 01:40:35 +080094 * Available settings (case-sensitive):
95 * - "commentStyle": "None" or "All"
96 * - "indentation": "<anything>".
97 * - Setting this to an empty string also omits newline characters.
98 * - "enableYAMLCompatibility": false or true
99 * - slightly change the whitespace around colons
100 * - "dropNullPlaceholders": false or true
101 * - Drop the "null" string from the writer's output for nullValues.
102 * Strictly speaking, this is not valid JSON. But when the output is being
103 * fed to a browser's JavaScript, it makes for smaller output and the
104 * browser can handle the output just fine.
105 * - "useSpecialFloats": false or true
106 * - If true, outputs non-finite floating point values in the following way:
107 * NaN values as "NaN", positive infinity as "Infinity", and negative
108 * infinity as "-Infinity".
109 * - "precision": int
110 * - Number of precision digits for formatting of real values.
111 * - "precisionType": "significant"(default) or "decimal"
112 * - Type of precision for formatting of real values.
PinkD1ee39a62021-03-02 23:57:54 +0800113 * - "emitUTF8": false or true
114 * - If true, outputs raw UTF8 strings instead of escaping them.
Christopher Dunnf757c182015-02-09 18:24:56 -0600115
dota17abcd3f72019-09-17 01:40:35 +0800116 * You can examine 'settings_` yourself
117 * to see the defaults. You can also write and read them just like any
118 * JSON Value.
119 * \sa setDefaults()
120 */
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600121 Json::Value settings_;
Christopher Dunn7eca3b42015-01-26 11:17:42 -0600122
123 StreamWriterBuilder();
Hans Johnson2853b1c2019-01-11 13:58:53 -0600124 ~StreamWriterBuilder() override;
Christopher Dunn6065a1c2015-01-26 11:01:15 -0600125
Christopher Dunnc41609b2015-02-09 18:44:53 -0600126 /**
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600127 * \throw std::exception if something goes wrong (e.g. invalid settings)
128 */
Hans Johnson2853b1c2019-01-11 13:58:53 -0600129 StreamWriter* newStreamWriter() const override;
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600130
Christopher Dunnf757c182015-02-09 18:24:56 -0600131 /** \return true if 'settings' are legal and consistent;
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600132 * otherwise, indicate bad settings via 'invalid'.
133 */
134 bool validate(Json::Value* invalid) const;
Christopher Dunnc312dd52015-03-04 14:56:37 -0600135 /** A simple way to update a specific setting.
136 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500137 Value& operator[](const String& key);
Christopher Dunnc312dd52015-03-04 14:56:37 -0600138
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600139 /** Called by ctor, but you can use this to reset settings_.
140 * \pre 'settings' != NULL (but Json::null is fine)
Christopher Dunn3cf91752015-02-09 18:16:24 -0600141 * \remark Defaults:
142 * \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
Christopher Dunna9e1ab32015-02-09 17:22:28 -0600143 */
144 static void setDefaults(Json::Value* settings);
Christopher Dunn6065a1c2015-01-26 11:01:15 -0600145};
Christopher Dunn5fbfe3c2015-01-22 14:31:32 -0600146
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000147/** \brief Abstract class for writers.
Christopher Dunned495ed2015-03-08 14:01:28 -0500148 * \deprecated Use StreamWriter. (And really, this is an implementation detail.)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000149 */
Christopher Dunn54a54322021-11-03 11:35:15 -0500150class JSON_API Writer {
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000151public:
152 virtual ~Writer();
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000153
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500154 virtual String write(const Value& root) = 0;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000155};
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000156
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000157/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format
158 *without formatting (not human friendly).
159 *
160 * The JSON document is written in a single line. It is not intended for 'human'
161 *consumption,
luzpaz5b45aa52018-02-08 20:05:50 -0500162 * but may be useful to support feature such as RPC where bandwidth is limited.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000163 * \sa Reader, Value
Christopher Dunn20d09672015-02-10 21:29:35 -0600164 * \deprecated Use StreamWriterBuilder.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000165 */
Hugh Bellamy72870652017-09-16 10:01:09 +0100166#if defined(_MSC_VER)
Motti Lanzkron9bb984a2017-09-11 16:14:52 +0300167#pragma warning(push)
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400168#pragma warning(disable : 4996) // Deriving from deprecated class
Hugh Bellamy72870652017-09-16 10:01:09 +0100169#endif
Christopher Dunn54a54322021-11-03 11:35:15 -0500170class JSON_API FastWriter
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400171 : public Writer {
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000172public:
173 FastWriter();
Hans Johnsone3e05c72019-01-14 17:09:26 -0600174 ~FastWriter() override = default;
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000175
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000176 void enableYAMLCompatibility();
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000177
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000178 /** \brief Drop the "null" string from the writer's output for nullValues.
179 * Strictly speaking, this is not valid JSON. But when the output is being
Josh Sorefe6a588a2017-12-03 11:54:29 -0500180 * fed to a browser's JavaScript, it makes for smaller output and the
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000181 * browser can handle the output just fine.
182 */
183 void dropNullPlaceholders();
Aaron Jacobsae3c7a72012-03-12 04:53:57 +0000184
Don Milham5bf16102014-09-02 17:09:07 -0600185 void omitEndingLineFeed();
186
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000187public: // overridden from Writer
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500188 String write(const Value& root) override;
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000189
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000190private:
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000191 void writeValue(const Value& value);
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000192
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500193 String document_;
Billy Donahue2b593a92019-01-18 03:46:57 -0500194 bool yamlCompatibilityEnabled_{false};
195 bool dropNullPlaceholders_{false};
196 bool omitEndingLineFeed_{false};
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000197};
Hugh Bellamy72870652017-09-16 10:01:09 +0100198#if defined(_MSC_VER)
Christopher Dunn132840a2017-09-11 13:39:38 -0500199#pragma warning(pop)
Hugh Bellamy72870652017-09-16 10:01:09 +0100200#endif
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000201
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000202/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
203 *human friendly way.
204 *
205 * The rules for line break and indent are as follow:
206 * - Object value:
207 * - if empty then print {} without indent and line break
208 * - if not empty the print '{', line break & indent, print one value per
209 *line
210 * and then unindent and line break and print '}'.
211 * - Array value:
212 * - if empty then print [] without indent and line break
213 * - if the array contains no object value, empty array or some other value
214 *types,
215 * and all the values fit on one lines, then print the array on a single
216 *line.
217 * - otherwise, it the values do not fit on one line, or the array contains
218 * object or non empty array, then print one value per line.
219 *
220 * If the Value have comments then they are outputed according to their
221 *#CommentPlacement.
222 *
223 * \sa Reader, Value, Value::setComment()
Christopher Dunn38042b32015-01-26 11:23:31 -0600224 * \deprecated Use StreamWriterBuilder.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000225 */
Hugh Bellamy72870652017-09-16 10:01:09 +0100226#if defined(_MSC_VER)
Motti Lanzkron9bb984a2017-09-11 16:14:52 +0300227#pragma warning(push)
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400228#pragma warning(disable : 4996) // Deriving from deprecated class
Hugh Bellamy72870652017-09-16 10:01:09 +0100229#endif
Christopher Dunn54a54322021-11-03 11:35:15 -0500230class JSON_API
Jordan Baylesf34bf242019-10-11 11:19:00 -0700231 StyledWriter : public Writer {
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000232public:
233 StyledWriter();
Hans Johnsone3e05c72019-01-14 17:09:26 -0600234 ~StyledWriter() override = default;
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000235
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000236public: // overridden from Writer
237 /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
238 * \param root Value to serialize.
239 * \return String containing the JSON document that represents the root value.
240 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500241 String write(const Value& root) override;
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000242
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000243private:
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000244 void writeValue(const Value& value);
245 void writeArrayValue(const Value& value);
Josh Sorefe6a588a2017-12-03 11:54:29 -0500246 bool isMultilineArray(const Value& value);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500247 void pushValue(const String& value);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000248 void writeIndent();
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500249 void writeWithIndent(const String& value);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000250 void indent();
251 void unindent();
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000252 void writeCommentBeforeValue(const Value& root);
253 void writeCommentAfterValueOnSameLine(const Value& root);
Marian Klymov48112c82018-06-02 19:43:31 +0300254 static bool hasCommentForValue(const Value& value);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500255 static String normalizeEOL(const String& text);
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000256
Chen2983f5a2019-12-04 09:08:45 +0800257 using ChildValues = std::vector<String>;
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000258
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000259 ChildValues childValues_;
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500260 String document_;
261 String indentString_;
Billy Donahue2b593a92019-01-18 03:46:57 -0500262 unsigned int rightMargin_{74};
263 unsigned int indentSize_{3};
264 bool addChildValues_{false};
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000265};
Hugh Bellamy72870652017-09-16 10:01:09 +0100266#if defined(_MSC_VER)
Christopher Dunn132840a2017-09-11 13:39:38 -0500267#pragma warning(pop)
Hugh Bellamy72870652017-09-16 10:01:09 +0100268#endif
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000269
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000270/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a
271 human friendly way,
272 to a stream rather than to a string.
273 *
274 * The rules for line break and indent are as follow:
275 * - Object value:
276 * - if empty then print {} without indent and line break
277 * - if not empty the print '{', line break & indent, print one value per
278 line
279 * and then unindent and line break and print '}'.
280 * - Array value:
281 * - if empty then print [] without indent and line break
282 * - if the array contains no object value, empty array or some other value
283 types,
284 * and all the values fit on one lines, then print the array on a single
285 line.
286 * - otherwise, it the values do not fit on one line, or the array contains
287 * object or non empty array, then print one value per line.
288 *
289 * If the Value have comments then they are outputed according to their
290 #CommentPlacement.
291 *
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000292 * \sa Reader, Value, Value::setComment()
Christopher Dunn38042b32015-01-26 11:23:31 -0600293 * \deprecated Use StreamWriterBuilder.
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000294 */
Hugh Bellamy72870652017-09-16 10:01:09 +0100295#if defined(_MSC_VER)
Christopher Dunn132840a2017-09-11 13:39:38 -0500296#pragma warning(push)
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400297#pragma warning(disable : 4996) // Deriving from deprecated class
Hugh Bellamy72870652017-09-16 10:01:09 +0100298#endif
Christopher Dunn54a54322021-11-03 11:35:15 -0500299class JSON_API
Jordan Baylesf34bf242019-10-11 11:19:00 -0700300 StyledStreamWriter {
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000301public:
Billy Donahueb5e1fe82018-05-20 16:55:27 -0400302 /**
303 * \param indentation Each level will be indented by this amount extra.
304 */
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500305 StyledStreamWriter(String indentation = "\t");
Hans Johnsonb5093e82019-01-14 17:09:19 -0600306 ~StyledStreamWriter() = default;
Christopher Dunn605cd7e2007-06-13 15:55:50 +0000307
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000308public:
309 /** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
310 * \param out Stream to write to. (Can be ostringstream, e.g.)
311 * \param root Value to serialize.
312 * \note There is no point in deriving from Writer, since write() should not
313 * return a value.
314 */
Jordan Baylesf34bf242019-10-11 11:19:00 -0700315 void write(OStream& out, const Value& root);
Christopher Dunn605cd7e2007-06-13 15:55:50 +0000316
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000317private:
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000318 void writeValue(const Value& value);
319 void writeArrayValue(const Value& value);
Josh Sorefe6a588a2017-12-03 11:54:29 -0500320 bool isMultilineArray(const Value& value);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500321 void pushValue(const String& value);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000322 void writeIndent();
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500323 void writeWithIndent(const String& value);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000324 void indent();
325 void unindent();
Aaron Jacobs11086dd2014-09-15 10:15:29 +1000326 void writeCommentBeforeValue(const Value& root);
327 void writeCommentAfterValueOnSameLine(const Value& root);
Marian Klymov48112c82018-06-02 19:43:31 +0300328 static bool hasCommentForValue(const Value& value);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500329 static String normalizeEOL(const String& text);
Christopher Dunn605cd7e2007-06-13 15:55:50 +0000330
Chen2983f5a2019-12-04 09:08:45 +0800331 using ChildValues = std::vector<String>;
Christopher Dunn605cd7e2007-06-13 15:55:50 +0000332
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000333 ChildValues childValues_;
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500334 OStream* document_;
335 String indentString_;
Billy Donahue2b593a92019-01-18 03:46:57 -0500336 unsigned int rightMargin_{74};
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500337 String indentation_;
Christopher Dunnd3830562015-01-23 13:09:43 -0600338 bool addChildValues_ : 1;
339 bool indented_ : 1;
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000340};
Hugh Bellamy72870652017-09-16 10:01:09 +0100341#if defined(_MSC_VER)
Christopher Dunn132840a2017-09-11 13:39:38 -0500342#pragma warning(pop)
Hugh Bellamy72870652017-09-16 10:01:09 +0100343#endif
Christopher Dunn605cd7e2007-06-13 15:55:50 +0000344
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000345#if defined(JSON_HAS_INT64)
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500346String JSON_API valueToString(Int value);
347String JSON_API valueToString(UInt value);
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000348#endif // if defined(JSON_HAS_INT64)
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500349String JSON_API valueToString(LargestInt value);
350String JSON_API valueToString(LargestUInt value);
Jordan Baylesf34bf242019-10-11 11:19:00 -0700351String JSON_API valueToString(
352 double value, unsigned int precision = Value::defaultRealPrecision,
353 PrecisionType precisionType = PrecisionType::significantDigits);
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500354String JSON_API valueToString(bool value);
355String JSON_API valueToQuotedString(const char* value);
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000356
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000357/// \brief Output using the StyledStreamWriter.
358/// \see Json::operator>>()
Billy Donahue1c2ed7a2019-01-17 16:35:29 -0500359JSON_API OStream& operator<<(OStream&, const Value& root);
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000360
361} // namespace Json
362
Sergiy80d6e666f2016-12-03 22:29:14 +0200363#pragma pack(pop)
364
Baptiste Lepilleureafd7022013-05-08 20:21:11 +0000365#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
Aaron Jacobs9fa4e842014-07-01 08:48:54 +1000366#pragma warning(pop)
Baptiste Lepilleureafd7022013-05-08 20:21:11 +0000367#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
368
Christopher Dunn6d135cb2007-06-13 15:51:04 +0000369#endif // JSON_WRITER_H_INCLUDED