aboutsummaryrefslogtreecommitdiff
path: root/src/univalue/univalue_write.cpp
diff options
context:
space:
mode:
authorJonas Schnelli <jonas.schnelli@include7.ch>2015-05-10 15:53:54 +0200
committerJonas Schnelli <jonas.schnelli@include7.ch>2015-06-04 09:16:06 +0200
commit0c5b2cf69ae20f83cbd894bb19d0e111623bae0f (patch)
tree5adf63f805d4908ce5224c83bea99a763dfdf21d /src/univalue/univalue_write.cpp
parent21c10de8c2de17a6357dbbcea7613b41f6ab8449 (diff)
univalue: add support for real, fix percision and make it json_spirit compatible
- avoid breaking the API because of different number/percision handling
Diffstat (limited to 'src/univalue/univalue_write.cpp')
-rw-r--r--src/univalue/univalue_write.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/univalue/univalue_write.cpp b/src/univalue/univalue_write.cpp
index 9a1d364c95..d360c253b0 100644
--- a/src/univalue/univalue_write.cpp
+++ b/src/univalue/univalue_write.cpp
@@ -3,6 +3,8 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <ctype.h>
+#include <iomanip>
+#include <sstream>
#include <stdio.h>
#include "univalue.h"
#include "univalue_escapes.h"
@@ -59,6 +61,13 @@ string UniValue::write(unsigned int prettyIndent,
case VSTR:
s += "\"" + json_escape(val) + "\"";
break;
+ case VREAL:
+ {
+ std::stringstream ss;
+ ss << std::showpoint << std::fixed << std::setprecision(8) << get_real();
+ s += ss.str();
+ }
+ break;
case VNUM:
s += val;
break;