blob: 78d0703ebbfb05a5f30e0fdbf6b78f707e29f394 [file] [log] [blame]
Austin Schuh3e95e5d2019-09-20 00:08:54 -07001#ifndef AOS_JSON_TO_FLATBUFFER_H_
2#define AOS_JSON_TO_FLATBUFFER_H_
3
4#include <cstddef>
5#include <string>
6
Austin Schuhd339a9b2019-10-05 21:33:32 -07007#include "absl/strings/string_view.h"
Austin Schuh3e95e5d2019-09-20 00:08:54 -07008#include "flatbuffers/flatbuffers.h"
9
10namespace aos {
11
12// Parses the flatbuffer into the vector, or returns an empty vector.
13::std::vector<uint8_t> JsonToFlatbuffer(
Austin Schuhd339a9b2019-10-05 21:33:32 -070014 const absl::string_view data, const flatbuffers::TypeTable *typetable);
Austin Schuh3e95e5d2019-09-20 00:08:54 -070015
16// Converts a flatbuffer into a Json string.
17//
18// multi_line controls if the Json is written out on multiple lines or one.
19::std::string FlatbufferToJson(const uint8_t *buffer,
20 const flatbuffers::TypeTable *typetable,
21 bool multi_line = false);
22
Austin Schuh3e95e5d2019-09-20 00:08:54 -070023} // namespace aos
24
25#endif // AOS_JSON_TO_FLATBUFFER_H_