aboutsummaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorWouter van Oortmerssen <wvo@google.com>2014-07-08 16:35:14 -0700
committerWouter van Oortmerssen <wvo@google.com>2014-07-09 11:43:30 -0700
commit7fcbe723fc821785abfec0348023d9ebf5b4db96 (patch)
tree3e6a55f5d0c1ae481a1f42535aad3bacf1447af5 /samples
parent9140144d5161124623a27cf8b8038f6e7c9bb74d (diff)
downloadflatbuffers-7fcbe723fc821785abfec0348023d9ebf5b4db96.tar.gz
Added a "strict JSON" mode to the text generator and compiler
This will add quotes around field names, as required by the official standard. By default it will leave quotes out, as it is more readable, more compact, and is accepted by almost all JSON parsers. The -S switch to flatc turns on strict mode. As per rfc 7159. Change-Id: Ibabe9c8162c47339d00ec581d18721a2ba40c6d0 Tested: on Windows.
Diffstat (limited to 'samples')
-rwxr-xr-xsamples/sample_text.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/samples/sample_text.cpp b/samples/sample_text.cpp
index a286e6f8..b1b7527c 100755
--- a/samples/sample_text.cpp
+++ b/samples/sample_text.cpp
@@ -46,7 +46,8 @@ 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(), 2, &jsongen);
+ GenerateText(parser, parser.builder_.GetBufferPointer(),
+ flatbuffers::GeneratorOptions(), &jsongen);
if (jsongen != jsonfile) {
printf("%s----------------\n%s", jsongen.c_str(), jsonfile.c_str());