aboutsummaryrefslogtreecommitdiff
path: root/docs/source
diff options
context:
space:
mode:
authormugisoba <51015092+mugisoba@users.noreply.github.com>2020-02-11 10:43:36 +0900
committerGitHub <noreply@github.com>2020-02-10 17:43:36 -0800
commit173e10fdf14884376eb6ed4590142394d69f62c6 (patch)
treeab138c851c87f04a604edc1a5d63db96853915f7 /docs/source
parent8f56990f6cbb2ea260c9da3a2985568d5408d4dd (diff)
downloadflatbuffers-173e10fdf14884376eb6ed4590142394d69f62c6.tar.gz
[C#] support Json Serialization (#5752)
* support json serialization * fix invalid json format. * string must be written with double quotes. * remove commma after the last object member. * fix indent * Revert "fix invalid json format." This reverts commit d6820ed50c8e3d3cda3aa1849b3079f853608619. * quated string value. * add cs-gen-json-serializer flag. * fix preprocessor indent * ENABLE_JSON_SERIALIZATION -> ENABLE_JSON_SERIALIZATION_TEST * share TestBuffer method * remove ENABLE_JSON_SERIALIZATION * remove duplicated test data * [windows] add nuget restore and copy test data. * [docker mono] share msbuild settings with windows. add nuget restore and copy test data. * add some note for json api.
Diffstat (limited to 'docs/source')
-rw-r--r--docs/source/CsharpUsage.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/source/CsharpUsage.md b/docs/source/CsharpUsage.md
index 90a757fb..f7f585db 100644
--- a/docs/source/CsharpUsage.md
+++ b/docs/source/CsharpUsage.md
@@ -151,4 +151,25 @@ To use:
fbb.Finish(Monster.Pack(fbb, monsterobj).Value);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+### Json Serialization
+
+An additional feature of the object API is the ability to allow you to
+serialize & deserialize a JSON text.
+To use Json Serialization, add `--gen-json-serializer` option to `flatc` and
+add `Newtonsoft.Json` nuget package to csproj.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cs}
+ // Deserialize MonsterT from json
+ string jsonText = File.ReadAllText(@"Resources/monsterdata_test.json");
+ MonsterT mon = MonsterT.DeserializeFromJson(jsonText);
+
+ // Serialize MonsterT to json
+ string jsonText2 = mon.SerializeToJson();
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+* Limitation
+ * `hash` attribute currentry not supported.
+* NuGet package Dependency
+ * [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json)
+
<br>