--------------------------------- Writer::WriteNumber Write a number
| 164 | // Write a number |
| 165 | // |
| 166 | bool Writer::WriteNumber(Number const* const jNum) |
| 167 | { |
| 168 | if (jNum == nullptr) |
| 169 | { |
| 170 | LOG("JSON::Writer::WriteNumber > Failed to write json number to string, number object was null", LogLevel::Warning); |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | // use either the double or int val. if its a double the ostream should automatically convert to scientific notation if necessary |
| 175 | if (jNum->isInt) |
| 176 | { |
| 177 | m_JsonString += std::to_string(jNum->valueInt); |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | std::ostringstream streamObj; |
| 182 | streamObj << jNum->value; |
| 183 | |
| 184 | std::string numString = streamObj.str(); |
| 185 | if (numString.find('.') == std::string::npos) |
| 186 | { |
| 187 | numString += ".0"; |
| 188 | } |
| 189 | |
| 190 | m_JsonString += numString; |
| 191 | } |
| 192 | |
| 193 | return true; |
| 194 | } |
| 195 | |
| 196 | //--------------------------------- |
| 197 | // Writer::WriteString |