! @brief serialization Serialization function for JSON values. The function tries to mimic Python's `json.dumps()` function, and currently supports its @a indent parameter. @param[in] indent If indent is nonnegative, then array elements and object members will be pretty-printed with that indent level. An indent level of `0` will only insert newlines. `-1` (the default
| 2198 | @since version 1.0.0 |
| 2199 | */ |
| 2200 | string_t dump(const int indent = -1) const |
| 2201 | { |
| 2202 | std::stringstream ss; |
| 2203 | // fix locale problems |
| 2204 | const static std::locale loc(std::locale(), new DecimalSeparator); |
| 2205 | ss.imbue(loc); |
| 2206 | |
| 2207 | // 6, 15 or 16 digits of precision allows round-trip IEEE 754 |
| 2208 | // string->float->string, string->double->string or string->long |
| 2209 | // double->string; to be safe, we read this value from |
| 2210 | // std::numeric_limits<number_float_t>::digits10 |
| 2211 | ss.precision(std::numeric_limits<double>::digits10); |
| 2212 | |
| 2213 | if (indent >= 0) |
| 2214 | { |
| 2215 | dump(ss, true, static_cast<unsigned int>(indent)); |
| 2216 | } |
| 2217 | else |
| 2218 | { |
| 2219 | dump(ss, false, 0); |
| 2220 | } |
| 2221 | |
| 2222 | return ss.str(); |
| 2223 | } |
| 2224 | |
| 2225 | /*! |
| 2226 | @brief return the type of the JSON value (explicit) |
no test coverage detected