Support structs in json_to_flatbuffer
Our JSON flatbuffer parsing code did not support structs properly.
Doing this enables easily defining lots of different layouts of
flatbuffers for more thoroughly testing flatbuffer-related changes (as
well as just making the JSON parsing more complete).
Change-Id: Ibfc7a149f9c8b314f6bbba70b4ca6b5857a8728b
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/json_tokenizer.cc b/aos/json_tokenizer.cc
index eab7fcc..d277c1e 100644
--- a/aos/json_tokenizer.cc
+++ b/aos/json_tokenizer.cc
@@ -531,14 +531,9 @@
return TokenType::kError;
}
-bool Tokenizer::FieldAsInt(long long *value) {
+bool Tokenizer::FieldAsInt(absl::int128 *value) {
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() + field_value().size() || errno != 0) {
- return false;
- }
- return true;
+ return absl::SimpleAtoi(pos, value);
}
bool Tokenizer::FieldAsDouble(double *value) {