Fix issues with json files
File parsing no longer uses istream, which strips whitespace. Moved hard-coded json to its own file.
Signed-off-by: Alexander Yee <xander.yee@gmail.com>
Change-Id: I342b74fd1cc8c5af7721af5955aa7d7b185ac71e
diff --git a/aos/json_to_flatbuffer.h b/aos/json_to_flatbuffer.h
index d5e1039..6eab22a 100644
--- a/aos/json_to_flatbuffer.h
+++ b/aos/json_to_flatbuffer.h
@@ -109,10 +109,8 @@
template <typename T>
inline FlatbufferDetachedBuffer<T> JsonFileToFlatbuffer(
const std::string_view path) {
- std::ifstream t{std::string(path)};
- std::istream_iterator<char> start(t), end;
- std::string result(start, end);
- return FlatbufferDetachedBuffer<T>(JsonToFlatbuffer<T>(result));
+ return FlatbufferDetachedBuffer<T>(
+ JsonToFlatbuffer<T>(util::ReadFileToStringOrDie(path)));
}
// Parses a file as a binary flatbuffer or dies.