diff options
author | Ben Hamilton <beng@fb.com> | 2016-08-18 10:14:32 -0700 |
---|---|---|
committer | Ben Hamilton <beng@fb.com> | 2016-08-18 10:23:26 -0700 |
commit | 94d5643f97102fffd9e0131541e9385d6d0b7e34 (patch) | |
tree | 3988807e9f4f95f37b1aebc5733fa81426674209 /samples/sample_text.cpp | |
parent | f0d91fa143eed6de915a41108287c260e82a2689 (diff) | |
download | flatbuffers-94d5643f97102fffd9e0131541e9385d6d0b7e34.tar.gz flatbuffers-94d5643f97102fffd9e0131541e9385d6d0b7e34.tar.bz2 flatbuffers-94d5643f97102fffd9e0131541e9385d6d0b7e34.zip |
Allow GenerateText() to indicate failure to encode flatbuffer to JSON (i.e., non-UTF-8 string data)
Diffstat (limited to 'samples/sample_text.cpp')
-rw-r--r-- | samples/sample_text.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/samples/sample_text.cpp b/samples/sample_text.cpp index 557077d4..d851120d 100644 --- a/samples/sample_text.cpp +++ b/samples/sample_text.cpp @@ -46,7 +46,10 @@ int main(int /*argc*/, const char * /*argv*/[]) { // to ensure it is correct, we now generate text back from the binary, // and compare the two: std::string jsongen; - GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen); + if (!GenerateText(parser, parser.builder_.GetBufferPointer(), &jsongen)) { + printf("Couldn't serialize parsed data to JSON!\n"); + return 1; + } if (jsongen != jsonfile) { printf("%s----------------\n%s", jsongen.c_str(), jsonfile.c_str()); |