Is there a way to get underlying bytes for a double value while parsing json using rapidjson.
Look at below code:
string temp_json2 = "{\"byte_size\":1000.3}";
rapidjson::Document doc;
doc.Parse<0>(temp_json2.c_str());
rapidjson::Value::ConstMemberIterator iter = doc.MemberBegin();
const rapidjson::Value& key = iter->name;
std::cout << key.GetString() << " = ";
const rapidjson::Value& val = iter->value;
std::cout << val.GetDouble();
I want to get something like
val.GetRawString(); instead of val.GetDouble();
Reason I need this is that I don't want any precision to be lost during conversion. Note that I don't have a choice to modifying json to put quotes around double value.
Currently no.
I am working on a "full-precision" parsing option (for quite long time) which can be precisely parse string into
double
. Thedouble
-to-string conversion is already exact using grisu2 algorithm. But if a string cannot be represented bydouble
precisely, it will still lose some precision.To support your requirement, it may need to add an parsing option, and changing the SAX and DOM interface. If you would like this feature to be implement, please report here for further discussion.