Convenient methods for JSON integer. (#5089)

* Fix parsing empty object.
This commit is contained in:
Jiaming Yuan
2019-12-05 11:01:12 +08:00
committed by GitHub
parent dcde433402
commit f0ca53d9ec
3 changed files with 24 additions and 6 deletions

View File

@@ -243,7 +243,7 @@ Json& JsonNumber::operator[](int ind) {
bool JsonNumber::operator==(Value const& rhs) const {
if (!IsA<JsonNumber>(&rhs)) { return false; }
return number_ == Cast<JsonNumber const>(&rhs)->getNumber();
return std::abs(number_ - Cast<JsonNumber const>(&rhs)->getNumber()) < kRtEps;
}
Value & JsonNumber::operator=(Value const &rhs) {
@@ -504,7 +504,10 @@ Json JsonReader::ParseObject() {
SkipSpaces();
char ch = PeekNextChar();
if (ch == '}') return Json(std::move(data));
if (ch == '}') {
GetChar('}');
return Json(std::move(data));
}
while (true) {
SkipSpaces();