Parse scientific notation Json numbers as double
This commit is contained in:
parent
572291047f
commit
ab03c224dd
@ -198,7 +198,7 @@ private:
|
|||||||
|
|
||||||
void number() {
|
void number() {
|
||||||
std::basic_string<char32_t> buffer;
|
std::basic_string<char32_t> buffer;
|
||||||
bool hasDot = false;
|
bool isDouble = false;
|
||||||
|
|
||||||
if (m_char == '-') {
|
if (m_char == '-') {
|
||||||
buffer += '-';
|
buffer += '-';
|
||||||
@ -218,7 +218,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_char == '.') {
|
if (m_char == '.') {
|
||||||
hasDot = true;
|
isDouble = true;
|
||||||
buffer += '.';
|
buffer += '.';
|
||||||
next();
|
next();
|
||||||
while (m_char >= '0' && m_char <= '9') {
|
while (m_char >= '0' && m_char <= '9') {
|
||||||
@ -228,6 +228,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_char == 'e' || m_char == 'E') {
|
if (m_char == 'e' || m_char == 'E') {
|
||||||
|
isDouble = true;
|
||||||
buffer += m_char;
|
buffer += m_char;
|
||||||
next();
|
next();
|
||||||
if (m_char == '-' || m_char == '+') {
|
if (m_char == '-' || m_char == '+') {
|
||||||
@ -240,7 +241,7 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasDot) {
|
if (isDouble) {
|
||||||
try {
|
try {
|
||||||
m_stream.putDouble(buffer.c_str(), buffer.length());
|
m_stream.putDouble(buffer.c_str(), buffer.length());
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user