Skip to content

Commit

Permalink
Added clarification about unions in JSON to the docs.
Browse files Browse the repository at this point in the history
Change-Id: I1f310636f8b74366b5b0fc73c7e106424583fc93
  • Loading branch information
Wouter van Oortmerssen committed Jan 7, 2015
1 parent 3ec8d7f commit b929c62
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/html/md__schemas.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ <h2>JSON Parsing</h2>
<ul>
<li>It accepts field names with and without quotes, like many JSON parsers already do. It outputs them without quotes as well, though can be made to output them using the <code>strict_json</code> flag.</li>
<li>If a field has an enum type, the parser will recognize symbolic enum values (with or without quotes) instead of numbers, e.g. <code>field: EnumVal</code>. If a field is of integral type, you can still use symbolic names, but values need to be prefixed with their type and need to be quoted, e.g. <code>field: "Enum.EnumVal"</code>. For enums representing flags, you may place multiple inside a string separated by spaces to OR them, e.g. <code>field: "EnumVal1 EnumVal2"</code> or <code>field: "Enum.EnumVal1 Enum.EnumVal2"</code>.</li>
<li>Similarly, for unions, these need to specified with two fields much like you do when serializing from code. E.g. for a field <code>foo</code>, you must add a field <code>foo_type: FooOne</code> right before the <code>foo</code> field, where <code>FooOne</code> would be the table out of the union you want to use.</li>
</ul>
<p>When parsing JSON, it recognizes the following escape codes in strings:</p>
<ul>
Expand Down
4 changes: 4 additions & 0 deletions docs/source/Schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ JSON:
representing flags, you may place multiple inside a string
separated by spaces to OR them, e.g.
`field: "EnumVal1 EnumVal2"` or `field: "Enum.EnumVal1 Enum.EnumVal2"`.
- Similarly, for unions, these need to specified with two fields much like
you do when serializing from code. E.g. for a field `foo`, you must
add a field `foo_type: FooOne` right before the `foo` field, where
`FooOne` would be the table out of the union you want to use.

When parsing JSON, it recognizes the following escape codes in strings:

Expand Down

0 comments on commit b929c62

Please sign in to comment.