Handle decimal points and empty messages.
We were not handling fields with decimal points, or empty messages. Fix
that.
Change-Id: Icde878d211b979a1377d72acfc7bd6aa71872cf1
diff --git a/aos/json_to_flatbuffer.cc b/aos/json_to_flatbuffer.cc
index d73089b..737bacb 100644
--- a/aos/json_to_flatbuffer.cc
+++ b/aos/json_to_flatbuffer.cc
@@ -926,7 +926,12 @@
ConsumeWhitespace();
- state_ = State::kExpectField;
+ if (Consume("}")) {
+ ConsumeWhitespace();
+ state_ = State::kExpectObjectEnd;
+ } else {
+ state_ = State::kExpectField;
+ }
return TokenType::kStartObject;
case State::kExpectField: {
@@ -1092,7 +1097,7 @@
const char *pos = field_value().c_str();
errno = 0;
*value = strtoll(field_value().c_str(), const_cast<char **>(&pos), 10);
- if (pos == field_value().c_str() || errno != 0) {
+ if (pos != field_value().c_str() + field_value().size() || errno != 0) {
return false;
}
return true;
@@ -1103,7 +1108,7 @@
errno = 0;
*value = strtod(field_value().c_str(), const_cast<char **>(&pos));
- if (pos == field_value().c_str() || errno != 0) {
+ if (pos != field_value().c_str() + field_value().size() || errno != 0) {
return false;
}
return true;