-
Notifications
You must be signed in to change notification settings - Fork 2
Supported Formats
hotchaipro edited this page Oct 24, 2018
·
10 revisions
Serialize.NET currently supports the following serialization formats:
- PBON - best size and performance, not readable
- Bencoding - good size (except binary), good performance, somewhat readable
- JSON - good size (except binary), good performance, very readable
- XML - bloated size, good performance, readable
Typical usage might be to first use a readable encoding such as JSON during development and then switch to PBON for production.
See below for a comparison of the following object encoded in the supported formats.
class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
Person person = new Person()
{
Id = 1,
Name = "Foo"
};PBON (10 bytes)
7B-01-01-01-02-03-46-6F-6F-7D {.....Foo}
BEncode (16 bytes)
64-31-3A-31-69-31-65-31-3A-32-33-3A-46-6F-6F-65 d1:1i1e1:23:Fooe
JSON (17 bytes)
7B-22-31-22-3A-31-2C-22-32-22-3A-22-46-6F-6F-22-7D {"1":1,"2":"Foo"}
XML (101 bytes)
3C-6F-62-6A-65-63-74-3E <object>
3C-6D-65-6D-62-65-72-20 <member
6B-65-79-3D-22-31-22-3E key="1">
3C-76-61-6C-75-65-3E-31 <value>1
3C-2F-76-61-6C-75-65-3E </value>
3C-2F-6D-65-6D-62-65-72 </member
3E-3C-6D-65-6D-62-65-72 ><member
20-6B-65-79-3D-22-32-22 key="2"
3E-3C-76-61-6C-75-65-3E ><value>
46-6F-6F-3C-2F-76-61-6C Foo</val
75-65-3E-3C-2F-6D-65-6D ue></mem
62-65-72-3E-3C-2F-6F-62 ber></ob
6A-65-63-74-3E ject>
Following are the serialized sizes of the objects used in the unit test benchmarks for comparison:
- PBON - 411 bytes
- Bencode - 927 bytes
- JSON - 1,062 bytes
- XML - 3,526 bytes
- PBON - 4,297 bytes
- Bencode - 9,562 bytes
- JSON - 11,044 bytes
- XML - 36,922 bytes