univalue: add support for real, fix percision and make it json_spirit compatible
- avoid breaking the API because of different number/percision handling
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user