MessagePack

https://msgpack.org/

MessagePack 是一种高效的二进制序列化格式。它允许您在多种语言(如 JSON)之间交换数据。但它更快更小。小整数被编码为一个字节,典型的短字符串除了字符串本身之外只需要一个额外的字节

//C#简单示例

  var contents =MessagePack.MessagePackSerializer.Serialize<List<Model>>(list);
  BytesToFile(contents, @"D:\temp\messagepack.txt");
  
 var bytes = System.IO.File.ReadAllBytes(@"D:\temp\messagepack.txt");
 var restore = MessagePack.MessagePackSerializer.Deserialize<List<Model>>(bytes)
  

实体示例

    [MessagePackObject]
    public class Model
    {
        [Key(0)]
        public string Address { get; set; }
        [Key(1)]
        public string Name { get; set; }
        [Key(2)]
        public int Id { get; set; }
        [Key(3)]
        public bool IsDeleted { get; set; }
    }
posted @ 2022-12-27 19:54  [在河之洲]  阅读(107)  评论(0编辑  收藏  举报