From: Wouter van Oortmerssen Date: Tue, 8 Jul 2014 23:35:14 +0000 (-0700) Subject: Added a "strict JSON" mode to the text generator and compiler X-Git-Tag: v1.0.1~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7fcbe723fc821785abfec0348023d9ebf5b4db96;p=platform%2Fupstream%2Fflatbuffers.git 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. --- diff --git a/docs/html/md__compiler.html b/docs/html/md__compiler.html index 21bd4d4..5129791 100644 --- a/docs/html/md__compiler.html +++ b/docs/html/md__compiler.html @@ -53,13 +53,15 @@ $(document).ready(function(){initNavTree('md__compiler.html','');});
Using the schema compiler
-

Usage:

flatc [ -c ] [ -j ] [ -b ] [ -t ] file1 file2 ..
+

Usage:

flatc [ -c ] [ -j ] [ -b ] [ -t ] [ -o PATH ] [ -S ] file1 file2 ..
 

The files are read and parsed in order, and can contain either schemas or data (see below). Later files can make use of definitions in earlier files. Depending on the flags passed, additional files may be generated for each file processed:

  • -c : Generate a C++ header for all definitions in this file (as filename_generated.h). Skips data.
  • -j : Generate Java classes.
  • -b : If data is contained in this file, generate a filename_wire.bin containing the binary flatbuffer.
  • -
  • -t : If data is contained in this file, generate a filename_wire.txt (for debugging).
  • +
  • -t : If data is contained in this file, generate a filename_wire.txt (for debugging).
  • +
  • -o PATH : Output all generated files to PATH (either absolute, or relative to the current directory). If omitted, PATH will be the current directory. PATH should end in your systems path separator, e.g. / or \.
  • +
  • -S : Generate strict JSON (field names are enclosed in quotes). By default, no quotes are generated.
diff --git a/docs/html/md__schemas.html b/docs/html/md__schemas.html index 57f7b27..6f1c6f6 100644 --- a/docs/html/md__schemas.html +++ b/docs/html/md__schemas.html @@ -84,7 +84,7 @@ root_type Monster;

Tables are the main way of defining objects in FlatBuffers, and consist of a name (here Monster) and a list of fields. Each field has a name, a type, and optionally a default value (if omitted, it defaults to 0 / NULL).

Each field is optional: It does not have to appear in the wire representation, and you can choose to omit fields for each individual object. As a result, you have the flexibility to add fields without fear of bloating your data. This design is also FlatBuffer's mechanism for forward and backwards compatibility. Note that:

@@ -119,7 +119,7 @@ root_type Monster;

Attributes may be attached to a declaration, behind a field, or after the name of a table/struct/enum/union. These may either have a value or not. Some attributes like deprecated are understood by the compiler, others are simply ignored (like priority), but are available to query if you parse the schema at runtime. This is useful if you write your own code generators/editors etc., and you wish to add additional information specific to your tool (such as a help text).

Current understood attributes: