mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 12:43:24 +00:00
[C#] add ObjectAPI Serialization Utility (#5785)
* [C#] add ObjectAPI Serialization Utility * set InitialBufferSize to 64k * rename SerializeToFlatBuffers to SerializeToBinary
This commit is contained in:
committed by
GitHub
parent
4749e77b0e
commit
7c37abe92d
@@ -61,6 +61,14 @@ public class ArrayTableT
|
||||
public string SerializeToJson() {
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
|
||||
}
|
||||
public static ArrayTableT DeserializeFromBinary(byte[] fbBuffer) {
|
||||
return ArrayTable.GetRootAsArrayTable(new ByteBuffer(fbBuffer)).UnPack();
|
||||
}
|
||||
public byte[] SerializeToBinary() {
|
||||
var fbb = new FlatBufferBuilder(0x10000);
|
||||
fbb.Finish(ArrayTable.Pack(fbb, this).Value);
|
||||
return fbb.DataBuffer.ToSizedArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user